For MacOS Catalina, visit Install mysql2 on MacOS Catalina
Installing mysql2
gem errors on MacOS Mojave.
Make sure openssl
is installed on Mac via Homebrew.
brew install openssl
Install mysql2
gem.
gem install mysql2 -v '0.5.2' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include
As of today Homebrew defaults to MySQL 8.0, OpenSSL 1.1 and mysql2 0.5 that work great all together out of the box. However to upgrade of my legacy applications from Rails 3.2 to more recent versions I had to setup local environment on my MacOS BigSur 11.1.
My goal was to install mysql2 gem version 0.3.x (this is only one allowing smooth migration from Rails 3.2 to Rails 4.2 through versions 4.0 and 4.1) together with mySQL 5.x. Both of them in turn depend on OpenSSL 1.0
Here is what worked for me:
Voilá: