I have Ruby and Rails installed with RVM in a Mac OS X Lion environment.
I made Rails work properly with the mysql2 gem (using the MAMP libs rather than a mysql install). So everything was fine…
Until I’ve tried to write a standalone ruby script (out of a Rails context). And now I can’t get the mysql2 gem to work.
From within the script or from the Ruby command line (irb), the
require "mysql2"
instruction leads to the following error:
1.9.2p290 :001 > require "mysql2"
dyld: lazy symbol binding failed: Symbol not found: _mysql_get_client_info
Referenced from: /Users/mick/.rvm/gems/ruby-1.9.2-p290/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
Expected in: flat namespace
dyld: Symbol not found: _mysql_get_client_info
Referenced from: /Users/mick/.rvm/gems/ruby-1.9.2-p290/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
Expected in: flat namespace
I’ve tried several stuff:
-
export DYLD_LIBRARY_PATH=/Applications/MAMP/Library/lib/mysql/:$DYLD_LIBRARY_PATH -
using
sudo ln -s /Applications/MAMP/Library/lib/mysql/libmysqlclient.16.dylib /usr/lib/libmysqlclient.16.dylib
Nothing worked. I think I’m gonna cry soon…
Strangely, this happened just today with a co-worker. Here’s what I did to fix it:
It was as simple as that. Hope it also works for you!