mac os x getting mysql and rails to work
So I couldn't resist and bought myself a MacBook Pro! It's my first week with my new toy and I'm really enjoying it.
But I need to do something useful with it so I started to prepare it to be my new development platform, starting with Ruby/Rails + MySQL: Here is where the fun begins!
After I installed both Rails and MySQL, I fired up a terminal an typed:
sudo gem install mysql
...and here is what u get
ERROR: Failed to build gem native extension.
If you google this error you will find a couple solutions and this is the one that worked for me:
ARCHFLAGS="-Os -arch x86_64 -fno-common"
sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
--with-mysql-config=/usr/local/mysql/bin/mysql_config
Now, confident enough, I created a sample rails app and tried to create the development database:
leo$ rake db:create (in /Users/leo/projects/test)
dyld: lazy symbol binding failed: Symbol not found: _mysql_init
Doesn't look happy yet huh? This took me a while to figure out but it turned out to be fairly simple.
I have no idea why but after I installed the gem I had the file mysql.bundle in two different places:
/Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle
/Library/Ruby/Gems/1.8/gems/mysql-2.7/mysql.bundle
The solution was to remove the first copy of the file. Now everything is working fine at this end!
I really hope this is useful to someone!