gem install mysql2 -v 'YOUR.VERSION.HERE' -- --with-mysql-config=/usr/local/opt/mysql-client/bin/mysql_config \
--srcdir=/usr/local/opt/mysql/include --platform=ruby \
--with-ldflags=-L/usr/local/opt/openssl/lib \
--with-cppflags=-I/usr/local/opt/openssl/include
On Mojave, High Sierra, or Catalina, using homebrew.
https://gist.github.com/fernandoaleman/ee3ac6957c2ba4f7d7d33a251d58b191#gistcomment-2910891