I updated all the packages I installed with Homebrew. MySQL got upgraded to 5.6.12 (from 5.5.27 or so):
$ mysql --version mysql Ver 14.14 Distrib 5.6.12, fo
I had to specify the ldflags and cppflags for it to compile correctly, like this:
ldflags
cppflags
gem install mysql2 -v '0.5.2' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include