Install MySQL gem in Snow Leopard

I really hate configuring stuff, I wish I could just sit in front of my computer and start coding, too bad that’s not our reality. Last Monday I spent a few hours fighting with my Ruby on Rails configuration. For some reason MySQL just wouldn’t work no matter what I did. It amazed me to read about how many people where having the same problem and that there were just as many solutions as people trying to fix it. Here is how I solved it for what is worth:

Depending on the way I tried to install the MySQL gem I either got one of the following errors

ERROR:  Error installing mysql: ERROR: Failed to build gem native extension.


dyld: lazy symbol binding failed: Symbol not found: _mysql_init Referenced from: /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle Expected in: dynamic lookup

I have 2 MySQL installations, one with MAMP and one in /usr/local so that just seemed to complicate things because I wanted to use the former one with Ruby on Rails, finally I tried using the following code which solved the problem for me

sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=`which mysql_config

The weird thing is that “which mysql_config” points to the MAMP installation, so don’t ask me why but its working 😉

Leave a Comment


No comments yet. Why don’t you start the discussion?

Leave a Reply

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