【发布时间】:2015-11-14 18:41:25
【问题描述】:
在 OSX Lion 上的 Gemfile 中列出“mysql2”时尝试“捆绑安装”时出错。我正在用 Rails 构建一个应用程序。如果我运行“捆绑安装”,它会永远挂起。首先,我尝试按照建议将 gem 文件修改为 'gem 'mysql2', :git => 'git://github.com/sodabrew/mysql2.git', :ref => 'a2800f'' 来解决这个问题在这里:https://github.com/brianmario/mysql2/pull/654。无限循环得到修复,我成功运行了 'bundle install' 但是当我运行 'rake db:create' 时,我收到了这个错误:
rake aborted!
LoadError: dlopen(/Users/macbook/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/mysql2-a2800f86754b/lib/mysql2/mysql2.bundle, 9): Library not loaded: /usr/local/lib/libmysqlclient.18.dylib
Referenced from: /Users/macbook/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/mysql2-a2800f86754b/lib/mysql2/mysql2.bundle
Reason: image not found - /Users/macbook/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/mysql2-a2800f86754b/lib/mysql2/mysql2.bundle
/Users/macbook/Desktop/tutorial/billingleap2/moviestore/config/application.rb:7:in `<top (required)>'
/Users/macbook/Desktop/tutorial/billingleap2/moviestore/Rakefile:4:in `<top (required)>'
我也尝试 'brew install mysql' 并且它成功了,但是在 'rake db:create' 上,我收到了这个错误:
#<Mysql2::Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)>
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "pool"=>5, "username"=>"root", "password"=>nil, "host"=>"localhost", "database"=>"moviestore_development"}, {:charset=>"utf8", :collation=>"utf8_unicode_ci"}
(If you set the charset manually, make sure you have a matching collation)
#<Mysql2::Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)>
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8","pool"=>5, "username"=>"root", "password"=>nil, "host"=>"localhost", "database"=>"moviestore_test"}, {:charset=>"utf8", :collation=>"utf8_unicode_ci"}
(If you set the charset manually, make sure you have a matching collation)
然后我'brew卸载mysql'并且那个问题消失了,但现在我有了第一个。
尝试 'gem install mysql2 -v '0.3.19'' 也会挂起。
可能是什么问题?
【问题讨论】:
-
请在此处粘贴您的 Gemfile 和 gemfile.lock
-
mysql 服务器进程是否正在运行并接受连接?错误消息表明没有进程正在接受连接。两种猜测:1) 没有 mysql 守护进程在运行 2) 有一个 mysql 守护进程在运行,但它不接受任何本地连接。我认为1)更有可能。安装完mysql是怎么启动的?
-
这里是 Gemfile:pastie.org/10365361,这里是 gemfile.lock:pastie.org/10365363
标签: mysql ruby-on-rails gem mysql2