rake db:migrate error with mysql2 gem - Library not loaded: libssl.1.0.0.dylib

First uninstall the mysql2 gem:

gem uninstall mysql2

Make sure you installed openssl:

brew install openssl

It will print out some notes. We are interested in this part:

For compilers to find this software you may need to set:
LDFLAGS:  -L/usr/local/opt/openssl/lib
CPPFLAGS: -I/usr/local/opt/openssl/include

Then you can re-install mysql2 gem like this:

gem install mysql2 -v 0.4.10 -- --with-cppflags=-I/usr/local/opt/openssl/include --with-ldflags=-L/usr/local/opt/openssl/lib

You should be good to go.


Following fix solves the issue

   ==> cd /usr/local/Cellar/openssl/1.0.2s/lib/

==> sudo cp libssl.1.0.0.dylib libcrypto.1.0.0.dylib /usr/local/lib