不正确的MySQL客户端库版本(Incorrect MySQL client library ver

2019-07-29 12:26发布

我创建了一个新的Rails项目通话

rails new simple_cms 

然后,当我在运行目录

rails s

我得到的后续错误

C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/l
ib/mysql2/mysql2.rb:2:in `require': Incorrect MySQL client library version! This
gem was compiled for 6.0.0 but the client library is 5.5.24. (RuntimeError)
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-
x86-mingw32/lib/mysql2/mysql2.rb:2:in `<top (required)>'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-
x86-mingw32/lib/mysql2.rb:9:in `require'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-
x86-mingw32/lib/mysql2.rb:9:in `<top (required)>'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/
lib/bundler/runtime.rb:68:in `require'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/
lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/
lib/bundler/runtime.rb:66:in `each'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/
lib/bundler/runtime.rb:66:in `block in require'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/
lib/bundler/runtime.rb:55:in `each'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/
lib/bundler/runtime.rb:55:in `require'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/
lib/bundler.rb:119:in `require'
    from c:/development/ruby/simple_cms/config/application.rb:7:in `<top (re
quired)>'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.3
/lib/rails/commands.rb:53:in `require'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.3
/lib/rails/commands.rb:53:in `block in <top (required)>'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.3
/lib/rails/commands.rb:50:in `tap'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.3
/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

我看到其他人有这个错误,但他们往往是Linux用户和我运行Windows。 我试图重新安装两个轨(railsinstaller.org)和MySQL 5.5。 我都用了32位版本和64位版本

Answer 1:

似乎有在这里已经有大约这几个问题。 你尝试他们的解决方案?

也许最清楚的是这样的: mysql2宝石编译错误的MySQL客户端库

相关的部分是在这里:

At the time of building this gem, the necessary DLL files where available
in the following download:

http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick

And put lib\libmysql.dll file in your Ruby bin directory, for example
C:\Ruby\bin


Answer 2:

这将消除宝石和它的依赖。 然后重新安装将重新编译本身和所有的依赖。

gem uninstall mysql2
bundle install


Answer 3:

我在一个新的项目我工作的其中有此错误突然停止在Windows机器,已经有工作轨道项目的工作,所以这显然不是安装问题。

是什么原因造成的问题是一个bundle update命令,决定重新下载mysql2宝石(原因不明),而忽视了我的Gemfile线的宝石'mysql2', '~> 0.2.6'

问题是,捆绑了更新版本的MySQL 0.2.18,如图Gemfile.lock的,在下面一行:

    mysql2 (0.2.18-x86-mingw32)

我注意到确保符号意味着什么,但我取代了以下线在我的Gemfile

gem 'mysql2', '~> 0.2.6'

对于

gem 'mysql2', '0.2.6'

而现在一切正常,包括bundle update



文章来源: Incorrect MySQL client library version