El Capitan 升级:未加载库:/usr/local/lib/libmysqlclient.18.dylib
El Capitan upgrade: Library not loaded: /usr/local/lib/libmysqlclient.18.dylib
错误:
/Users/askar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/mysql2-0.3.20/lib/mysql2.rb:31:in `require': dlopen(/Users/askar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/mysql2-0.3.20/mysql2/mysql2.bundle, 9): Library not loaded: /usr/local/lib/libmysqlclient.18.dylib (LoadError)
Referenced from: /Users/askar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/mysql2-0.3.20/mysql2/mysql2.bundle
Reason: image not found - /Users/askar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/mysql2-0.3.20/mysql2/mysql2.bundle
在 Gemfile 中:gem 'mysql2'
$ ls -al /usr/local/lib/libmysql*
lrwxr-xr-x 1 askar admin 49 Nov 13 10:48 /usr/local/lib/libmysqlclient.20.dylib -> ../Cellar/mysql/5.7.9/lib/libmysqlclient.20.dylib
lrwxr-xr-x 1 askar admin 42 Nov 13 10:48 /usr/local/lib/libmysqlclient.a -> ../Cellar/mysql/5.7.9/lib/libmysqlclient.a
lrwxr-xr-x 1 askar admin 46 Nov 13 10:48 /usr/local/lib/libmysqlclient.dylib -> ../Cellar/mysql/5.7.9/lib/libmysqlclient.dylib
lrwxr-xr-x 1 askar admin 37 Nov 13 10:48 /usr/local/lib/libmysqld.a -> ../Cellar/mysql/5.7.9/lib/libmysqld.a
lrwxr-xr-x 1 askar admin 44 Nov 13 10:48 /usr/local/lib/libmysqlservices.a -> ../Cellar/mysql/5.7.9/lib/libmysqlservices.a
$ ls -al /usr/local/Cellar/mysql/5.7.9/lib/
total 84392
drwxr-xr-x 9 askar admin 306 Nov 12 22:16 .
drwxr-xr-x 14 askar admin 476 Nov 13 10:48 ..
-r--r--r-- 1 askar admin 3780168 Nov 13 10:48 libmysqlclient.20.dylib
-r--r--r-- 1 askar admin 4280752 Nov 12 22:16 libmysqlclient.a
lrwxr-xr-x 1 askar admin 23 Nov 12 22:16 libmysqlclient.dylib -> libmysqlclient.20.dylib
-r--r--r-- 1 askar admin 35126528 Nov 12 22:16 libmysqld.a
-r--r--r-- 1 askar admin 9048 Nov 12 22:16 libmysqlservices.a
drwxr-xr-x 3 askar admin 102 Nov 13 10:48 pkgconfig
drwxr-xr-x 43 askar admin 1462 Nov 12 22:17 plugin
drwxr-xr-x 43 askar admin 1462 Nov 12 22:17 plugin
如您所见,我有 libmysqlclient.20.dylib
,它是 20
而不是 18
,否则我会按照 here.
的解决方案
我最近升级到 El Capitan,但不确定是不是这个原因。
更新:
感谢@Rashmirathi 提示重新安装 gem。
只是想说明一下,我还需要在 Gemfile 中指定为:
gem 'mysql2', '~> 0.3.18'
否则我有错误:
Specified 'mysql2' for database adapter, but the gem is not loaded. Add gem 'mysql2'
to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
但最后我得到了错误:
Mysql2::Error
Your password has expired. To log in you must change it using a client that supports expired passwords.
重新设置密码解决:
SET PASSWORD=PASSWORD('your_password');
我早些时候遇到了同样的问题,我通过重新安装 gem mysql2
.
修复了它
这将解决您的问题:
gem pristine mysql2
solution by Cesar Sulbarán
只想在这里插话 - 我刚刚遇到了与 libmysql 客户端相同的问题。18.dylib 18-20 的差异。重新安装 mysql
gem(activerecord-mysql-adapter
的依赖项)有所不同。重新安装 mysql2
没有任何作用。
编辑澄清:我的错误消息追溯到我的 mysql gem,但我通过搜索找到了这个线程,所以我将它包括在这里:
Please install the mysql adapter: `gem install activerecord-mysql-adapter` (dlopen(/Users/eriks/.rvm/gems/ruby-2.1.4/gems/mysql-2.9.1/lib/mysql/mysql_api.bundle, 9):
Library not loaded: /usr/local/lib/libmysqlclient.18.dylib
Referenced from: /Users/eriks/.rvm/gems/ruby-2.1.4/gems/mysql-2.9.1/lib/mysql/mysql_api.bundle
Reason: image not found - /Users/eriks/.rvm/gems/ruby-2.1.4/gems/mysql-2.9.1/lib/mysql/mysql_api.bundle) (LoadError)
我在 python 中遇到了类似的问题:libmysqlclient.20.dylib
而不是 El Capitan 上的 18
。 pip install --upgrade mysql
修复了它,但仅适用于 python2.
对于 OS X El Capitan 或更高级别的用户,这解决了我的问题:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib
更多信息
我正在使用 Homebrew,所以我通过逐步清理所有内容解决了这个问题:
注释掉 Rails 应用程序 Gemfile
中的 mysql2 gem
"# gem 'mysql2'"
从捆绑
中删除mysql2gem
捆绑安装
卸载mysql2gem(所有版本)
gem卸载mysql2
更新 Homebrew
酿造更新
卸载所有版本mysql
brew uninstall --force mysql
重新安装mysql
brew 安装mysql
在 Gemfile
中取消注释 mysql2 gem
gem mysql2
将 mysql2 添加到捆绑包
捆绑安装
这种方法可能有点矫枉过正,但我觉得很干净。
错误:
/Users/askar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/mysql2-0.3.20/lib/mysql2.rb:31:in `require': dlopen(/Users/askar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/mysql2-0.3.20/mysql2/mysql2.bundle, 9): Library not loaded: /usr/local/lib/libmysqlclient.18.dylib (LoadError)
Referenced from: /Users/askar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/mysql2-0.3.20/mysql2/mysql2.bundle
Reason: image not found - /Users/askar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/mysql2-0.3.20/mysql2/mysql2.bundle
在 Gemfile 中:gem 'mysql2'
$ ls -al /usr/local/lib/libmysql*
lrwxr-xr-x 1 askar admin 49 Nov 13 10:48 /usr/local/lib/libmysqlclient.20.dylib -> ../Cellar/mysql/5.7.9/lib/libmysqlclient.20.dylib
lrwxr-xr-x 1 askar admin 42 Nov 13 10:48 /usr/local/lib/libmysqlclient.a -> ../Cellar/mysql/5.7.9/lib/libmysqlclient.a
lrwxr-xr-x 1 askar admin 46 Nov 13 10:48 /usr/local/lib/libmysqlclient.dylib -> ../Cellar/mysql/5.7.9/lib/libmysqlclient.dylib
lrwxr-xr-x 1 askar admin 37 Nov 13 10:48 /usr/local/lib/libmysqld.a -> ../Cellar/mysql/5.7.9/lib/libmysqld.a
lrwxr-xr-x 1 askar admin 44 Nov 13 10:48 /usr/local/lib/libmysqlservices.a -> ../Cellar/mysql/5.7.9/lib/libmysqlservices.a
$ ls -al /usr/local/Cellar/mysql/5.7.9/lib/
total 84392
drwxr-xr-x 9 askar admin 306 Nov 12 22:16 .
drwxr-xr-x 14 askar admin 476 Nov 13 10:48 ..
-r--r--r-- 1 askar admin 3780168 Nov 13 10:48 libmysqlclient.20.dylib
-r--r--r-- 1 askar admin 4280752 Nov 12 22:16 libmysqlclient.a
lrwxr-xr-x 1 askar admin 23 Nov 12 22:16 libmysqlclient.dylib -> libmysqlclient.20.dylib
-r--r--r-- 1 askar admin 35126528 Nov 12 22:16 libmysqld.a
-r--r--r-- 1 askar admin 9048 Nov 12 22:16 libmysqlservices.a
drwxr-xr-x 3 askar admin 102 Nov 13 10:48 pkgconfig
drwxr-xr-x 43 askar admin 1462 Nov 12 22:17 plugin
drwxr-xr-x 43 askar admin 1462 Nov 12 22:17 plugin
如您所见,我有 libmysqlclient.20.dylib
,它是 20
而不是 18
,否则我会按照 here.
我最近升级到 El Capitan,但不确定是不是这个原因。
更新:
感谢@Rashmirathi 提示重新安装 gem。
只是想说明一下,我还需要在 Gemfile 中指定为:
gem 'mysql2', '~> 0.3.18'
否则我有错误:
Specified 'mysql2' for database adapter, but the gem is not loaded. Add
gem 'mysql2'
to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
但最后我得到了错误:
Mysql2::Error
Your password has expired. To log in you must change it using a client that supports expired passwords.
重新设置密码解决:
SET PASSWORD=PASSWORD('your_password');
我早些时候遇到了同样的问题,我通过重新安装 gem mysql2
.
这将解决您的问题:
gem pristine mysql2
solution by Cesar Sulbarán
只想在这里插话 - 我刚刚遇到了与 libmysql 客户端相同的问题。18.dylib 18-20 的差异。重新安装 mysql
gem(activerecord-mysql-adapter
的依赖项)有所不同。重新安装 mysql2
没有任何作用。
编辑澄清:我的错误消息追溯到我的 mysql gem,但我通过搜索找到了这个线程,所以我将它包括在这里:
Please install the mysql adapter: `gem install activerecord-mysql-adapter` (dlopen(/Users/eriks/.rvm/gems/ruby-2.1.4/gems/mysql-2.9.1/lib/mysql/mysql_api.bundle, 9):
Library not loaded: /usr/local/lib/libmysqlclient.18.dylib
Referenced from: /Users/eriks/.rvm/gems/ruby-2.1.4/gems/mysql-2.9.1/lib/mysql/mysql_api.bundle
Reason: image not found - /Users/eriks/.rvm/gems/ruby-2.1.4/gems/mysql-2.9.1/lib/mysql/mysql_api.bundle) (LoadError)
我在 python 中遇到了类似的问题:libmysqlclient.20.dylib
而不是 El Capitan 上的 18
。 pip install --upgrade mysql
修复了它,但仅适用于 python2.
对于 OS X El Capitan 或更高级别的用户,这解决了我的问题:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib
更多信息
我正在使用 Homebrew,所以我通过逐步清理所有内容解决了这个问题:
注释掉 Rails 应用程序 Gemfile
中的 mysql2 gem"# gem 'mysql2'"
从捆绑
中删除mysql2gem捆绑安装
卸载mysql2gem(所有版本)
gem卸载mysql2
更新 Homebrew
酿造更新
卸载所有版本mysql
brew uninstall --force mysql
重新安装mysql
brew 安装mysql
在 Gemfile
中取消注释 mysql2 gemgem mysql2
将 mysql2 添加到捆绑包
捆绑安装
这种方法可能有点矫枉过正,但我觉得很干净。