mysql2 gem compiled for wrong mysql client library

Rahul picture Rahul · Jan 5, 2012 · Viewed 57k times · Source

When try to connect to the mysql server through my rails application, I get the following error

D:/Program_Files/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': 
Incorrect MySQL client library version! This gem was compiled for 6.0.0 but the client library is 5.0.27. (RuntimeError)

How can I rectify it?

Answer

chrislopresto picture chrislopresto · Mar 4, 2013

Uninstalling and reinstalling the gem will often solve this issue with no need to download and move files around by hand. From your rails app directory:

> gem uninstall mysql2

You have requested to uninstall the gem:
    mysql2-0.3.11
database_cleaner-0.9.1 depends on [mysql2 (>= 0)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn]  Y
Successfully uninstalled mysql2-0.3.11

> bundle install

Fetching gem metadata from http://rubygems.org/......
Fetching gem metadata from http://rubygems.org/..
Using rake (0.9.2)
Using i18n (0.6.1)
... <SNIP> ...
Installing mysql2 (0.3.11) with native extensions
... <SNIP> ...
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.