Homebrew MySQL 5.7 and gem 'mysql2' incompatibility | NetEngine

Homebrew MySQL 5.7 and gem 'mysql2' incompatibility

Package managers are awesome! I love how easy Homebrew and RubyGems make it to keep your system up to date.

MySQL 5.7 is now the default in Homebrew. brew install mysql and brew upgrade will install 5.7

This version was made the default in Homebrew as of 4th of November 2015.

Older versions of the mysql2 gem do not work with MySQL 5.7 out of the box.

If you are working on project with the mysql2 gem older than v0.4.0, v0.3.17, or v0.2.24 you will see something like this:

NameError: uninitialized constant Mysql2::Client::SECURE_CONNECTION

The fix was created on 23 Oct 2014 but the issue has gone unnoticed by those using Homebrew since we had MySQL 5.6.

If you come across this in a project, please upgrade the gem to at least v0.4.0, v0.3.17, v0.2.24. Even better, upgrade to the more recent versions.

This will save headaches when trying to set up projects that use a default Homebrew install.

There are a few discussions about the issue on GitHub: