2012-05-23 108 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 
相關問題