使用Mysql2 for Ruby

时间:2011-11-09 15:17:17

标签: mysql ruby-on-rails ruby ruby-on-rails-3 rubygems

我尝试运行rails S并得到以下错误。

 /Users/ME/.rvm/gems/ruby-1.9.2-p290/gems/mysql2-0.3.8/lib/mysql2.rb:9:in `require':     dlopen(/Users/KaushiK/.rvm/gems/ruby-1.9.2-p290/gems/mysql2-0.3.8/lib/mysql2/mysql2.bundle, 9): Library not loaded: /usr/local/mysql-5.5.10-osx10.6-x86_64/lib/libmysqlclient.18.dylib (LoadError)
Referenced from: /Users/ME/.rvm/gems/ruby-1.9.2-p290/gems/mysql2-0.3.8/lib/mysql2/mysql2.bundle
Reason: image not found - /Users/KaushiK/.rvm/gems/ruby-1.9.2-p290/gems/mysql2-0.3.8/lib/mysql2/mysql2.bundle
from /Users/ME/.rvm/gems/ruby-1.9.2-p290/gems/mysql2-0.3.8/lib/mysql2.rb:9:in `<top (required)>'
from /Users/ME/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
from /Users/ME/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /Users/ME/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
from /Users/ME/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require'
from /Users/ME/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'
from /Users/ME/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'
from /Users/ME/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
from /Users/ME/Desktop/MyRailProjects/first_app/config/application.rb:7:in `<top (required)>'
from /Users/ME/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/commands.rb:52:in `require'
from /Users/ME/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/commands.rb:52:in `block in <top (required)>'
from /Users/ME/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/commands.rb:49:in `tap'
from /Users/ME/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/commands.rb:49:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

我按照上一个帖子(http://stackoverflow.com/questions/5394873/trying-to-access-my-ruby-project-loaderror-pertaining-to-mysql)编写了以下内容,

 sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql-5.5.10- osx10.7-x86_64/lib/libmysqlclient.18.dylib /Users/ME/.rvm/gems/ruby-1.9.2-p290/gems/mysql2-0.3.8/lib/mysql2/mysql2.bundle 

哪个什么都没做。我的意思是它经历了然后我写了这个。

sudo ln /usr/local/mysql-5.5.10-osx10.7-x86_64/bin/mysql /usr/local/mysql/bin/mysql

当我输入时,它说

 ln: /usr/local/mysql-5.5.10-osx10.7-x86_64/bin/mysql: No such file or directory

我不知道为什么。即使我启用了查看隐藏文件,我也看不到文件和目录。我不知道如何调试这个。

1 个答案:

答案 0 :(得分:1)

除非您必须使用Oracle破坏的MySQL 5.5软件包,否则最简单的解决方案是降低到5.1。那说......

当你说install_name工具“什么也没做”时,你的意思是什么?你之后再次尝试建造宝石了吗?给予“无所事事”的外观是UNIX工具的标准成功状态。

Re:ln,即使是最新版本仍标记为10.6。除非你自己重命名MySQL目录,否则它是mysql-5.5.10-osx10。 6 -x86_64。