gem install mysql2 - fails with MySQL 5.6.12

Posted by Anton Katunin on 24 June 2013
Tags: mysql, gem, mysql2, mysql 5.6.12, code

If you installed the latest mysql with homebrew, my version of mysql was 5.6.12. I couldn't install mysql2 gem

gem install mysql2

will output

 /Users/anton/.rbenv/versions/1.9.3-p286/bin/ruby extconf.rb 
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for mysql.h... no
checking for mysql/mysql.h... no
-----
mysql.h is missing.  please check your installation of mysql and try again.
-----
*** 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.

....

after checking forums, relinking include paths and failing at everything else, turns out it doesn't work for mysql version 5.6.12, so that answer on stackoverflow helped me.

http://stackoverflow.com/a/17252887/987533

Copy of solution:

Uninstall MySQL 5.6.12:

brew unlink mysql
brew uninstall mysql

Go to the homebrew directory:

cd /usr/local

Go to version 5.6.10 (you can find a list of versions by running brew versions mysql:

git checkout 48f7e86 Library/Formula/mysql.rb

Then install mysql again:

brew install mysql

And install gem

gem install mysql2

Read next:

Quickly open files in iTerm with RubyMine on MacOS