2012-05-23 59 views
6

我创建了一个新的Rails项目调用不正确的MySQL客户端库版本

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位版本

+0

+1问相关问题 – neeraj

回答

13

这里已经有几个问题了。你试过他们的解决方案吗?

可能是最清楚的是这样的: mysql2 gem compiled 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 
+0

我看到一个。我错过了关于移动libmysql.dll的最后一步。现在它工作。谢谢! – mhopkins321

+1

+1用于节省我的额外工作量 – neeraj

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

4

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

gem uninstall mysql2 
bundle install 
相关问题