2015-11-19 103 views
8

原因:找不到图像 - /Users/mdurrant/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin- 14/2.1.0静电/ mysql2-0.3.20/mysql2/mysql2.bundlerails-mysql rake db:create - 未加载库libmysqlclient.20.dylib找不到图像

我们的应用程序需要MySQL 5.6版,这似乎是确定的工作 -

$ mysql -uroot 
Welcome to the MySQL monitor. Commands end with ; or \g. 
Your MySQL connection id is 1 
Server version: 5.6.27 MySQL Community Server (GPL) 
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. 
Oracle is a registered trademark of Oracle Corporation and/or its 
affiliates. Other names may be trademarks of their respective 
owners. 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 
mysql> 

然而,当我尝试创建数据库从铁路我得到:

$ rake db:create 
rake aborted! 
LoadError: dlopen(/Users/mdurrant/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-14/2.1.0-static/mysql2-0.3.20/mysql2/mysql2.bundle, 9): Library not loaded: /usr/local/opt/mysql/lib/libmysqlclient.20.dylib 
    Referenced from: /Users/mdurrant/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-14/2.1.0-static/mysql2-0.3.20/mysql2/mysql2.bundle 
    Reason: image not found - /Users/mdurrant/.rvm/gems/ruby-2.1.5/extensions/x86_64-darwin-14/2.1.0-static/mysql2-0.3.20/mysql2/mysql2.bundle 
/Users/mdurrant/.rvm/gems/ruby-2.1.5/gems/activesupport-3.2.22/lib/active_support/dependencies.rb:251:in `require' 
/Users/mdurrant/.rvm/gems/ruby-2.1.5/gems/activesupport-3.2.22/lib/active_support/dependencies.rb:251:in `block in require' 
/Users/mdurrant/.rvm/gems/ruby-2.1.5/gems/activesupport-3.2.22/lib/active_support/dependencies.rb:236:in `load_dependency' 
/Users/mdurrant/.rvm/gems/ruby-2.1.5/gems/activesupport-3.2.22/lib/active_support/dependencies.rb:251:in `require' 
/Users/mdurrant/.rvm/gems/ruby-2.1.5/gems/mysql2-0.3.20/lib/mysql2.rb:31:in `<top (required)>' 
/Users/mdurrant/.rvm/gems/ruby-2.1.5/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `require' 
/Users/mdurrant/.rvm/gems/ruby-2.1.5/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `block (2 levels) in require' 
/Users/mdurrant/.rvm/gems/ruby-2.1.5/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `each' 
/Users/mdurrant/.rvm/gems/ruby-2.1.5/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `block in require' 
/Users/mdurrant/.rvm/gems/ruby-2.1.5/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `each' 
/Users/mdurrant/.rvm/gems/ruby-2.1.5/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `require' 
/Users/mdurrant/.rvm/gems/ruby-2.1.5/gems/bundler-1.10.6/lib/bundler.rb:134:in `require' 
/Users/mdurrant/eq/lynx/config/application.rb:10:in `<top (required)>' 
/Users/mdurrant/eq/lynx/Rakefile:10:in `require' 
/Users/mdurrant/eq/lynx/Rakefile:10:in `<top (required)>' 
/Users/mdurrant/.rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `eval' 
/Users/mdurrant/.rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `<main>' 
(See full trace by running task with --trace) 
14:18:13 mdurrant EQ-267 /Users/mdurrant/eq/lynx master 
$ 

回答

22

修复是对

gem uninstall mysql2 

然后用

bundle # gem install mysql2 would also work 

此重新编译,并解决了已经从有mysql安装5.7.9遗留的基准重新安装一遍。

+0

完美地解决了它 – Ben

+0

也为我解决。这是正确的答案。如果您愿意,请将其标记为正确。 – lucasarruda

+0

它为我工作 – kalpa

0

OS X无法找到libmysqlclient.18.dylib库。为了使访问,我们可以做到以下几点:

export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH 

到你的〜/ .bash_profile中,不要忘了后它来源: $源在〜/ .bash_profile

sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib 
+0

添加更多的细节到您的答案和格式,使其更具可读性。 – Takarii

相关问题