Dec 11, 2008

Quick Tip: Solve no such file to load -- mysql on Mac OSX

I recently had a problem on my MacOS X Leopard install where I couldn't get the mysql gem to install. I kept getting an error that said "no such file to load -- mysql". I tried googling around a bit and finally found a solution. Turns out there are several problems including the version of MySQL... apparently the x86_64 version has problems with Ruby. So you'll need the pure x86 version instead. That still won't solve your problem though so read on for the full instructions.

First thing you'll want to do is confirm you've got the right version of MySQL installed. Run this command and confirm the output is mysql -> mysql-5.1.30-osx10.5-x86

ls -l /usr/local

If you see the x86_64 version you'll need to reinstall MySQL. Backup all your databases first and then install MySQL again. You can download a package for MacOS X 10.4 and 10.5 from their site.

Once you've got the right version of MySQL installed, grabbing the gem is as simple as running

sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config