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

0

This error appears constantly, in my case, I installed ruby, gems, rails, mysql2 all right. But when I tried:

rake db:create

Another error appeared:

Gem :: LoadError: Specified 'mysql2' for database adapter, but the gem is not loaded. Add gem 'mysql2' to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). Gem :: LoadError: can not activate mysql2 (~> 0.3.13), already activated mysql2-0.4.0. Make sure all dependencies are added to Gemfile.

In this case, any attempt I attempted to generate error, the solution I found was, access the Gemfile and change to:

# Use mysql as the database for Active Record
gem 'mysql2', '~> 0.3.13'

I saved and executed:

bundle exec rake db:create

I love you!

I hope I can help someone else with this post.

    
asked by anonymous 15.09.2015 / 17:52

1 answer

0

Actually, for some reason that I do not know, there is a Rails 4.2.4 incompatibility problem with this new mysql2 0.4.0, so if you use the second newer version 0.3.20, it will work.

gem 'mysql2', '~> 0.3.20'
bundle install

I hope I have helped in some way.

Thanks.

    
16.09.2015 / 03:51