Incorrect MySQL client library version

2019-04-29 08:48发布

I created a new rails project calling

rails new simple_cms 

Then when in the directory I run

rails s

I get the follow errors

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>'

I have seen other people with this error but they tend to be linux users and I am running windows. I have attempted to reinstall both rails (railsinstaller.org) and mysql 5.5. I have used both the 32bit version as well as the 64bit version

3条回答
2楼-- · 2019-04-29 09:34

There seem to be several questions on here already about this. Did you try their solutions?

Probably the most clear is this: mysql2 gem compiled for wrong mysql client library

The pertinent part is here:

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
查看更多
萌系小妹纸
3楼-- · 2019-04-29 09:40

I had this error in a new project I was working on which suddenly stopped working in a windows machine that already had working rails projects, so it was clearly not an installation problem.

What caused the problem was a bundle update command, which decided to redownload mysql2 gem (for unknown reasons) and ignored my Gemfile line gem 'mysql2', '~> 0.2.6'.

The problem was that bundle update got mysql version 0.2.18, as shown in Gemfile.lock, in the following line:

    mysql2 (0.2.18-x86-mingw32)

I'm note sure what the symbol means, but I replaced the following line in my gemfile

gem 'mysql2', '~> 0.2.6'

for

gem 'mysql2', '0.2.6'

And now everything works fine, including bundle update.

查看更多
劫难
4楼-- · 2019-04-29 09:44

This will remove the gem and its dependencies. Then reinstalling will re-compile itself and all dependencies.

gem uninstall mysql2
bundle install
查看更多
登录 后发表回答