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.
So I ran into this similar issue and for me it turned out to be a wrong ruby version and incompatible MySQL version. I use ruby 2.3 on most of my projects but inherited a 2.1 project. Changing to rvm to use 2.1 got me a little further.
Then I found this: https://github.com/brianmario/mysql2/issues/603 that said you had to use mysql2 gem version greater than 0.3.17 with MySQL version 5.7
Updated gem to 0.3.17 and it fired right up. Hope this helps someone.
When you install openssl via brew, you should get the following message:
You can set these build flags (for the local application) by running the following:
This worked for me.
See bundler's documentation for more information.
I have a problem like this. Hope this could be useful .
brew install mysql@5.6
brew link mysql@5.6 --force
bundle install
this answer help me !
Try installing xcode-select --install
I am here to share my fix, since the other answers didn't work.
For my environment, I need MySQL 5.6 so I had to use:
brew install mysql56
instead ofbrew install mysql
Bundle installing the mysql2 gem kept failing, until:
brew link mysql56
I also ran afterwards:
mysql.server start
The last step might be unnecessary, but just in case.
I just had the same problem, tried all of the solutions listed above, then commenced to bang my head against they keyboard for a couple of hours.
I then thought to try and install/reinstall the Xcode Command Line Tools:
Once I did that the mysql2 gem installed w/ no problems. I hope that does the trick!