Gem::Loaderror Specified 'mysql2' for database Adapter, but the Gem is not Loaded. Add `Gem 'mysql2'` to your Gemfile

Asked

Viewed 827 times

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::Loadero: can’t 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 was looking for generated an error, the solution I found was, access Gemfile and change to:

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

saved and executed:

bundle exec rake db:create

voalá db created!

I hope I can help someone else with this post.

1 answer

0


In fact, for some unknown reason, there is a problem of incompatibility of Rails 4.2.4 with this newer 0.4.0 of mysql2, so if you use the second newer version 0.3.20, it will work.

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

I hope I’ve helped in some way.

Thanks.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.