Incorrect MySQL client library version! This gem was compiled for 5.6.21 but the client library is 10.0.14-MariaDB

If you get the following error, you probably have to reinstall your mysql2 gem by specifying the location of your MariaDB or MySQL installation.

The Error:

Navid:my_project navid$ rails s
/Users/navid/.rvm/gems/ruby-1.9.3-p125@my_project/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require': Incorrect MySQL client library version! This gem was compiled for 5.6.21 but the client library is 10.0.14-MariaDB. (RuntimeError)
	from /Users/navid/.rvm/gems/ruby-1.9.3-p125@my_project/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `block in require'
	from /Users/navid/.rvm/gems/ruby-1.9.3-p125@my_project/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `block in load_dependency'
	from /Users/navid/.rvm/gems/ruby-1.9.3-p125@my_project/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:596:in `new_constants_in'
	from /Users/navid/.rvm/gems/ruby-1.9.3-p125@my_project/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `load_dependency'
	from /Users/navid/.rvm/gems/ruby-1.9.3-p125@my_project/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require'
	from /Users/navid/.rvm/gems/ruby-1.9.3-p125@my_project/gems/mysql2-0.2.11/lib/mysql2.rb:9:in `<top (required)>'
	from /Users/navid/.rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.7.3/lib/bundler/runtime.rb:76:in `require'
	from /Users/navid/.rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.7.3/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
	from /Users/navid/.rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.7.3/lib/bundler/runtime.rb:72:in `each'
	from /Users/navid/.rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.7.3/lib/bundler/runtime.rb:72:in `block in require'
	from /Users/navid/.rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.7.3/lib/bundler/runtime.rb:61:in `each'
	from /Users/navid/.rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.7.3/lib/bundler/runtime.rb:61:in `require'
	from /Users/navid/.rvm/gems/ruby-1.9.3-p125@global/gems/bundler-1.7.3/lib/bundler.rb:133:in `require'
	from /Users/navid/src/some_project/apps/my_project/config/application.rb:11:in `<top (required)>'
	from /Users/navid/.rvm/gems/ruby-1.9.3-p125@my_project/gems/railties-3.0.3/lib/rails/commands.rb:28:in `require'
	from /Users/navid/.rvm/gems/ruby-1.9.3-p125@my_project/gems/railties-3.0.3/lib/rails/commands.rb:28:in `block in <top (required)>'
	from /Users/navid/.rvm/gems/ruby-1.9.3-p125@my_project/gems/railties-3.0.3/lib/rails/commands.rb:27:in `tap'
	from /Users/navid/.rvm/gems/ruby-1.9.3-p125@my_project/gems/railties-3.0.3/lib/rails/commands.rb:27:in `<top (required)>'
	from script/rails:6:in `require'
	from script/rails:6:in `<main>'

Uninstall existing mysql2 gem:

Navid:my_project navid$ gem list | grep mysql
mysql2 (0.2.11)

Navid:my_project navid$ gem uninstall mysql2
Successfully uninstalled mysql2-0.2.11

Install mysql2 gem again:

gem install mysql2 -- --with-mysql-config=/usr/local/Cellar/mariadb/10.0.14/bin/mysql_config

If you still see issues:

Here is the error you might see:

Navid:my_project navid$ bundle
...

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /Users/navid/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb 
checking for rb_thread_blocking_region()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
	--with-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/Users/navid/.rvm/rubies/ruby-1.9.3-p125/bin/ruby
	--with-mysql-config
	--without-mysql-config
	--with-mysql-dir
	--without-mysql-dir
	--with-mysql-include
	--without-mysql-include=${mysql-dir}/include
	--with-mysql-lib
	--without-mysql-lib=${mysql-dir}/lib
	--with-mysqlclientlib
	--without-mysqlclientlib
	--with-mlib
	--without-mlib
	--with-mysqlclientlib
	--without-mysqlclientlib
	--with-zlib
	--without-zlib
	--with-mysqlclientlib
	--without-mysqlclientlib
	--with-socketlib
	--without-socketlib
	--with-mysqlclientlib
	--without-mysqlclientlib
	--with-nsllib
	--without-nsllib
	--with-mysqlclientlib
	--without-mysqlclientlib
	--with-mygcclib
	--without-mygcclib
	--with-mysqlclientlib
	--without-mysqlclientlib

extconf failed, exit code 1

Gem files will remain installed in /Users/navid/.rvm/gems/ruby-1.9.3-p125@my_project/gems/mysql2-0.2.11 for inspection.
Results logged to /Users/navid/.rvm/gems/ruby-1.9.3-p125@my_project/extensions/x86_64-darwin-13/1.9.1/mysql2-0.2.11/gem_make.out
An error occurred while installing mysql2 (0.2.11), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.2.11'` succeeds before bundling.
brew info mysql
brew uninstall mysql

Uninstall existing mysql2 gem:

Navid:my_project navid$ gem list | grep mysql
mysql2 (0.2.11)

Navid:my_project navid$ gem uninstall mysql2
Successfully uninstalled mysql2-0.2.11

Install mysql2 gem again:

gem install mysql2 -- --with-mysql-config=/usr/local/Cellar/mariadb/10.0.14/bin/mysql_config

The error message above actually says that mysql2 gem version 0.2.11 version is missing. Do this to install that version:

gem install mysql2 -v '0.2.11' -- --with-mysql-config=/usr/local/Cellar/mariadb/10.0.14/bin/mysql_config
VN:F [1.9.22_1171]
Rating: 3.0/5 (2 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)
Incorrect MySQL client library version! This gem was compiled for 5.6.21 but the client library is 10.0.14-MariaDB, 3.0 out of 5 based on 2 ratings
Facebook Twitter Email

Leave a Reply