8

我创建了一个新的 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。我试图重新安装 rails (railsinstaller.org) 和 mysql 5.5。32位版本和64位版本我都用过

4

3 回答 3

13

这里似乎已经有几个关于这个的问题。您尝试过他们的解决方案吗?

最清楚的可能是这个: mysql2 gemcompiled for wrong mysql client library

相关部分在这里:

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
于 2012-05-23T18:18:57.610 回答
4

这将删除 gem 及其依赖项。然后重新安装将重新编译自身和所有依赖项。

gem uninstall mysql2
bundle install
于 2015-06-12T19:45:49.737 回答
0

我在一个正在处理的新项目中遇到了这个错误,该项目突然停止在一台已经有工作轨道项目的 Windows 机器上工作,所以这显然不是安装问题。

导致问题的原因是一个bundle update命令,它决定重新下载 mysql2 gem(原因不明)并忽略了我的 Gemfile 行 gem '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.

于 2013-06-04T11:26:35.020 回答