can't activate mysql2 (~> 0.3.6), already activated mysql2-0.3.2 in Rails 3.1 can't activate mysql2 (~> 0.3.6), already activated mysql2-0.3.2 in Rails 3.1 mysql mysql

can't activate mysql2 (~> 0.3.6), already activated mysql2-0.3.2 in Rails 3.1


Active Record has it's own requirements on which versions of mysql2 are compatible. Here's the line of code for Rails 3.1. You must use a version of mysql2 that satisfies these requirements.

Please install the mysql2 adapter: gem install activerecord-mysql2-adapter (can't activate mysql2 (~> 0.3.6), already activated mysql2-0.3.2. Make sure all dependencies are added to Gemfile.)

This is saying Rails expects a mysql2 version greater than 0.3.6 and less than 0.4.0, but found version 0.3.2. If you change your Gemfile to request a version in this range then Active Record should be happy. Perhaps

gem 'mysql2', '0.3.6'

Don't forget to update your bundle after changing your Gemfile.

bundle update mysql2


I know this is a very old thread but because it still comes up in Google results a one of the first results I though I would updated it with I had to do work around this issue in newer versions of Rails.

The errors shows as:

Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile 

followed by:

Gem::LoadError: can't activate mysql2 (< 0.5, >= 0.3.13), already activated mysql2-0.5.2. Make sure all dependencies are added to Gemfile.

I already had the gem added in my Gemfile as shown below:

group :production do  gem 'mysql2'end

but I had to update it to prevent from picking up a version outside of the range indicated in the error message. Notice the '< 0.5' below:

group :production do  gem 'mysql2', '< 0.5'end

Additionally, different versions of Rails set different min/max version restrictions for the MySQL gem:

From https://github.com/brianmario/mysql2/issues/950#issuecomment-376375844

"Correct, Rails 4.x cannot use mysql2 0.5.x. The actual code would work fine, but Rails 4 has a version restriction in place to prevent use of mysql2 0.5.x. This is intentional, as it allows future changes to the API without silently risking their use in older code not prepared to use the new APIs. There's also nothing magic about the version numbers -- it's totally by coincidence that Rails 4 uses mysql2 0.4 and Rails 5 will be able to use mysql2 0.4 or 0.5."


This also had me pulling out my hair. To only reasonable solution I could get was to switch to the master branch of the mysql2 gem.

gem 'mysql2', :git => 'git://github.com/brianmario/mysql2.git'

After this update my Rails 3.1.0.rc5 application could start with MySQL. (At the time of this post the latest version of the gem was 0.3.6)