如何修复libmysqlclient.15.dylib未加载导致的错误?

时间:2009-02-05 21:19:46

标签: mysql ruby-on-rails rubygems

我已升级到Rails 2.2.2并安装了MySQL 2.7 gem,当我尝试运行迁移或启动服务器时看到此错误:

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

有什么问题?

4 个答案:

答案 0 :(得分:4)

为了别人的利益回答我自己的问题。

我找到了修正here

执行命令

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

为我工作。

答案 1 :(得分:4)

我不得不从旧引用中删除目录:

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 :(得分:2)

使用sudo通常会导致意外问题。对我有用的是卸载mysql2 gem并重新安装它。

gem uninstall mysql2 bundle

答案 3 :(得分:1)

如果Gabe Hollombe解决方案不起作用,请尝试此

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