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)とmysql5.5の両方を再インストールしようとしました。32ビットバージョンと64ビットバージョンの両方を使用しました

4

3 に答える 3

13

これについては、すでにいくつかの質問があるようです。彼らの解決策を試しましたか?

おそらく最も明確なのはこれです: 間違ったmysqlクライアントライブラリ用にコンパイルされたmysql2gem

関連する部分はここにあります:

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

私が取り組んでいた新しいプロジェクトでこのエラーが発生しましたが、すでにRailsプロジェクトが機能しているWindowsマシンで突然機能しなくなったため、インストールの問題ではないことは明らかです。

問題の原因は、bundle updatemysql2 gemを(不明な理由で)再ダウンロードすることを決定し、私のGemfile行gemを無視するコマンドでした'mysql2', '~> 0.2.6'

問題は、Gemfile.lockに示されているように、次の行でバンドル更新がmysqlバージョン0.2.18を取得したことでした。

    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 に答える