How to fix error caused by libmysqlclient.15.dylib not being loaded?

↘锁芯ラ 提交于 2019-12-18 21:53:24

问题


I've upgraded to Rails 2.2.2 and installed the MySQL 2.7 gem and am seeing this error when I try to run a migration or start the server:

dlopen(/Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle, 9): Library not loaded: /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle
Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle

What's the fix?


回答1:


I had to remove the directory from the old references:

sudo install_name_tool -change libmysqlclient.18.dylib
    /usr/local/mysql/lib/libmysqlclient.18.dylib
    /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle

sudo install_name_tool -change libmysqlclient.18.dylib 
    /usr/local/mysql/lib/libmysqlclient.18.dylib
    /Library/Ruby/Gems/1.8/gems/mysql-2.7/mysql.bundle



回答2:


Answering my own question for the benefit of others.

I found the fix here.

Run:

sudo install_name_tool -change /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib /usr/local/mysql/lib/libmysqlclient.15.dylib /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle
sudo install_name_tool -change /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib /usr/local/mysql/lib/libmysqlclient.15.dylib /Library/Ruby/Gems/1.8/gems/mysql-2.7/mysql.bundle

Worked for me.




回答3:


Using sudo can often lead to unexpected issues. What worked for me was uninstalling the mysql2 gem and reinstalling it.

gem uninstall mysql2 bundle




回答4:


If Gabe Hollombe solution doesn't works then try this

sudo install_name_tool -change libmysqlclient.15.dylib /usr/local/mysql/lib/libmysqlclient.15.dylib /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle

sudo install_name_tool -change libmysqlclient.15.dylib /usr/local/mysql/lib/libmysqlclient.15.dylib /Library/Ruby/Gems/1.8/gems/mysql-2.7/mysql.bundle


来源:https://stackoverflow.com/questions/517976/how-to-fix-error-caused-by-libmysqlclient-15-dylib-not-being-loaded

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!