Installing Mysql 2 gem fails

You're installing an older version of the gem (0.4.5). I had the same issue (using 0.4.3). Installing version 0.4.10 solved this for me.

Try this:

gem install mysql2 -v 0.4.10

If that installs cleanly, you'll have to update your Gemfile to require this version:

gem 'mysql2', '~> 0.4.10'

Don't install a newer version of the gem (i.e. 0.5.x), they won't work with Rails 4 or older releases of Rails 5 (before 5.0.7/5.1.6) (see https://github.com/brianmario/mysql2/issues/950).


According to MySQL 5.7 document MYSQL_SECURE_AUTH has been enabled by default in 5.7, because of that the mysql2 not compile below the version 0.4.10 to the MySQL => 5.7

  • https://github.com/brianmario/mysql2/releases/tag/0.4.10
  • https://github.com/brianmario/mysql2/issues/891
  • https://dev.mysql.com/doc/refman/5.6/en/mysql-options.html