Archive for the ‘mysql’ Tag

 

Installing ruby-mysql on OS X Leopard

October 23rd, 2008
By: Steven Haddox
1 Comment »

So I was receiving a lovely deprecation warning from Rails tonight that if I didn’t install the C-library mysql adapter for Ruby then my applications would stop working in my environment when Rails 2.2 is released.  I decided it couldn’t be too hard to install the adapter and found out that there are a few problems with using the default gem install mysql when you are running the OS X Leopard mysql.com installation.

Anyway, the short and sweet of this is that there is a solution if your mysql gem install is giving you grief in Leopard. Simply run the following command and take note of the options in the parameter –cflags after the -I/usr/local/mysql/include directory. Those options will need to be passed in as your ARCHFLAGS value when you execute your gem install:

$ mysql_config
Usage: /usr/local/mysql/bin/mysql_config [OPTIONS]
Options:
        --cflags         [-I/usr/local/mysql/include -Os -arch x86_64 -fno-common]
        --include        [-I/usr/local/mysql/include]
        --libs           [-L/usr/local/mysql/lib -lmysqlclient -lz -lm]
        --libs_r         [-L/usr/local/mysql/lib -lmysqlclient_r -lz -lm]
        --socket         [/tmp/mysql.sock]
        --port           [3306]
        --version        [5.0.51b]
        --libmysqld-libs [-L/usr/local/mysql/lib -lmysqld -lz -lm]

In my instance (on a Mac Pro and MacBook Pro) I was able to get ruby-mysql working with the following command:

$ sudo env ARCHFLAGS="-Os -arch x86_64 -fno-common" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config