$ > gem install mysql2
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
checking for rbthreadblockingregion()... yes
checking for rbwaitforsinglefd()... yes
checking for rbhashdup()... yes
checking for rbintern3()... 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.
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:
Gem files will remain installed in /Users/dfang/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/mysql2-0.3.13 for inspection.
Results logged to /Users/dfang/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/mysql2-0.3.13/ext/mysql2/gem_make.out
there are duplicate questions in google, but not works
the solution works for me is :
gem install mysql2 --with-mysql-config=/usr/local/Cellar/mysql/5.6.12/bin/mysql_config
replace 5.6.12 to your version
you can dig into mysql cellar directory to find you version number
brew --cellar mysql
Hope it helps