fudge
fudge

Reputation: 19

Ruby on Rails error: Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile

Ok I have read countless articles on this same problem and I cannot get past this. I am new to Rails and I don't know much about what I'm doing but I get this error every time I run a rails server:

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).

require path_to_adapter
      rescue Gem::LoadError => e
        raise Gem::LoadError, "Specified '#{spec[:adapter]}' for database adapter, but the gem is not loaded. Add `gem '#{e.name}'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord)."
      rescue LoadError => e
        raise LoadError, "Could not load '#{path_to_adapter}'. Make sure that the adapter in config/database.yml is valid. If you use an adapter other than 'mysql', 'mysql2', 'postgresql' or 'sqlite3' add the necessary adapter gem to the Gemfile.", e.backtrace
      end

What do I do? I've done everything on these two threads but nothing changes.

Gem::LoadError for mysql2 gem, but it's already in Gemfile

Rails: Specified 'mysql2' for database adapter but the gem is not loaded

Upvotes: 0

Views: 2693

Answers (1)

sugaryourcoffee
sugaryourcoffee

Reputation: 879

Had the same error with Rails 4. I have down graded mysql2 gem 0.4.x to 0.3.20 in my Gemfile. Then ran bundle upgrade mysql2

Upvotes: 1

Related Questions