MySQL客户端库版本不正确!这个gem编译为5.5.37,但客户端库是5.6.25

时间:2015-07-29 08:25:35

标签: mysql ruby-on-rails gem rails-migrations ubuntu-15.04

我将Ubuntu从2014.04升级到2015.04,现在bundle exec rake db:migrate返回错误:

$ bundle exec rake db:migrate --trace
rake aborted!
Incorrect MySQL client library version! This gem was compiled for 5.5.37 but the client library is 5.6.25.
/home/nico/.rvm/gems/ruby-1.9.3-p362/gems/mysql2-0.2.11/lib/mysql2.rb:9:in `require'
/home/nico/.rvm/gems/ruby-1.9.3-p362/gems/mysql2-0.2.11/lib/mysql2.rb:9:in `<top (required)>'
/home/nico/.rvm/gems/ruby-1.9.3-p362@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `require'
/home/nico/.rvm/gems/ruby-1.9.3-p362@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
/home/nico/.rvm/gems/ruby-1.9.3-p362@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `each'
/home/nico/.rvm/gems/ruby-1.9.3-p362@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `block in require'
/home/nico/.rvm/gems/ruby-1.9.3-p362@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `each'
/home/nico/.rvm/gems/ruby-1.9.3-p362@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `require'
/home/nico/.rvm/gems/ruby-1.9.3-p362@global/gems/bundler-1.2.3/lib/bundler.rb:128:in `require'
/home/nico/myapp/config/application.rb:7:in `<top (required)>'
/home/nico/myapp/Rakefile:4:in `require'
/home/nico/myapp/Rakefile:4:in `<top (required)>'
/home/nico/.rvm/gems/ruby-1.9.3-p362@global/gems/rake-10.0.3/lib/rake/rake_module.rb:25:in `load'
/home/nico/.rvm/gems/ruby-1.9.3-p362@global/gems/rake-10.0.3/lib/rake/rake_module.rb:25:in `load_rakefile'
/home/nico/.rvm/gems/ruby-1.9.3-p362@global/gems/rake-10.0.3/lib/rake/application.rb:583:in `raw_load_rakefile'
/home/nico/.rvm/gems/ruby-1.9.3-p362@global/gems/rake-10.0.3/lib/rake/application.rb:89:in `block in load_rakefile'
/home/nico/.rvm/gems/ruby-1.9.3-p362@global/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/home/nico/.rvm/gems/ruby-1.9.3-p362@global/gems/rake-10.0.3/lib/rake/application.rb:88:in `load_rakefile'
/home/nico/.rvm/gems/ruby-1.9.3-p362@global/gems/rake-10.0.3/lib/rake/application.rb:72:in `block in run'
/home/nico/.rvm/gems/ruby-1.9.3-p362@global/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/home/nico/.rvm/gems/ruby-1.9.3-p362@global/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/home/nico/.rvm/gems/ruby-1.9.3-p362@global/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
/home/nico/.rvm/gems/ruby-1.9.3-p362@global/bin/rake:19:in `load'
/home/nico/.rvm/gems/ruby-1.9.3-p362@global/bin/rake:19:in `<main>'
/home/nico/.rvm/gems/ruby-1.9.3-p362/bin/ruby_noexec_wrapper:14:in `eval'
/home/nico/.rvm/gems/ruby-1.9.3-p362/bin/ruby_noexec_wrapper:14:in `<main>'

如何解决这个问题?
我宁愿避免更改服务器端版本。

I can't run "bundle update" because of "mysql2" gem的答案无法解决问题。

本地版本:

  • gem 2.4.8
  • Rails 3.0.19
  • mysql Ver 14.14 Distrib 5.6.25

2 个答案:

答案 0 :(得分:4)

运行这些命令解决了问题:

gem uninstall mysql2
bundle install

答案 1 :(得分:0)

我遇到了同样的问题,并且接受的答案对我没有用,很可能是因为我使用了capistrano,它将所有宝石安装到每个应用程序的共享目录中。

bundle show mysql2

(在您应用程序的文件夹中运行)将显示安装mysql的位置。然后删除它以及规范。

rm -rf /path/to/application/shared/bundle/ruby/<version>/gems/mysql2-<version>
rm /path/to/application/shared/bundle/ruby/<version>/specifications/mysql2-<version>.gemspec

应该做的伎俩。或者,只需删除完整的包/ *并重新安装所有内容。

相关问题