I'm setting up my development environment in the new macOS Sierra .
First of all, I installed Rbenv, Ruby (2.3.1), Homebrew and so the latest version of MySQL (5.7.15).
$ brew install mysql
$ mysql.server start
Ok, MySQL was initialized. Time to install the mysql2 gem...
$ gem install mysql2 -- --with-mysql-config=/usr/local/Cellar/mysql/5.7.15/bin/mysql_config
But it didn't work.
Almost the same scenario as @Caio Tarifa, Ruby 2.3.3, mysql 5.6 and mysql2. Tried on couple of solutions above and finally make it work with @kylekeesling's approach.
First, tried on solution 1 by @spickermann:
Nothing happened, same error shown.
Second, tried on solution by @Alessandro Berardi:
This got different but more errors since it overwrite gem extension's config so all gem extension installation failed.
Finally, tried on @kylekeesling solution:
It fix mysql gem issue as well as nikogiri. Since I already intall Xcode, in my case it's reinstall the Xcode Command Line Tools.
First, you should try 2 answer in here If you installed openssl but it still don't work. You should try to o refresh gems reference. A got the same issue and it worked for me.
gem source -r https://rubygems.org/
gem source -a https://rubygems.org/