Gem::LoadError
Specified 'mysql2' for database adapter, but the gem is not loaded.
Add `gem 'mysql2'` to your Gemfile
This error occurred while loading the following files:
active_record/base
This is the error I get on running rails server.
The mysql2 gem has been added to the Gemfile as well.
I've done bundle install
, and tried restarting the server but still get the error.
I have previously installed mysql2 0.4.5 but that was giving me this error so i have installed another version of mysql2 by:
gem install mysql2 --version 0.3.20
Hope this solves your problem.
I got the same error after an upgrade to Rails 4.1 and I managed to resolve it by updating mysql2. Run this in your rails app folder:
If you have this error when upgrading to rails 4.2.4 (also with rails 4.1.5) try using this version of mysql2:
Apparently mysql2 isn't still compatible with newer version of rails because rails 4.2.4 is pretty new as the time of answering this question by me 8 September 2015 so use the above line in your Gem file and run:
You should be good to go
It worked for me when I specified a mysql2 gem version before the newest one (0.4.0). For some reason there is a problem with Rails 4.2.4 and that gem 0.4.0. So, to solve the problem I just specified the previous gem released: 0.3.20 and it worked fine for me!
You can check all the gems versions here: https://rubygems.org/gems/mysql2/versions
Here is how I fixed this:
Credits: How do you undo bundle install --without
I solved the problem, installing the mysql2 gem local (gem install mysql2, bundle install) and adding the following line to the Gemfile:
gem 'mysql2'
Setting the mysql2 adapter in database.yml
adapter: mysql2
was also important!