Environment (Mac OS X 10.7.2 - Lion):
$ ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10]
$ rails -v
Rails 3.1.3
$ mysql -v
Server version: 5.1.44
I try running the following but I'm greeted with the same error every time even after applying fixes from all over the web:
$ rails server
dyld: lazy symbol binding failed: Symbol not found: _mysql_get_client_info
Referenced from: /Users/pressplay/.rvm/gems/ruby-1.9.3-p0/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
Expected in: flat namespace
dyld: Symbol not found: _mysql_get_client_info
Referenced from: /Users/pressplay/.rvm/gems/ruby-1.9.3-p0/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
Expected in: flat namespace
Trace/BPT trap: 5
Failed attempts at fixing include:
sudo install_name_tool -change libmysqlclient.16.dylib /Applications/MAMP/Library/lib/mysql/libmysqlclient.16.dylib ~/.rvm/gems/ruby-1.9.3-p0/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
sudo ln -s /Applications/MAMP/Library/lib/mysql/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
user1518115
if you are using rvm/without rvm(just use sudo) then please use the following command which solve the issues.
rvmsudo ARCHFLAGS="-arch x86_64" gem install mysql2 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config --with-opt-lib=/usr/local/mysql/lib
Uninstalling mysql2 gem and then installing gem with sudo solved it for me.
gem uninstall mysql2
sudo gem install mysql2
I can just add that you first need to uninstall the mysql2 gem and then reinstall with the instructions above.
sudo gem uninstall mysql2
来源:https://stackoverflow.com/questions/8612243/ruby-on-rails-server-wont-start-dyld-lazy-symbol-binding-failed-symbol-not-f