How to install mysql gem on OS X Snow Leopard

If there is an error when staring a Rails application via a MySQL connection:

Status: 500 Internal Server Error
uninitialized constant MysqlCompat::MysqlRes

Assume MySQL is already installed, for example, via homebrew: brew install mysql or other means.

1. Un-install the existing mysql gem (if any):
sudo gem uninstall mysql
2. Locate the ‘mysql_config’ file:
find /usr -name 'mysql_config'
3. Re-install mysql gem:
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/bin/mysql_config
Note: replace ‘/usr/local/bin/’ with the corresponding mysql_config path found in step 2.

cheers~

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>