Read more

Fix error: Missing the mysql2 gem

Henning Koch
August 07, 2012Software engineer at makandra GmbH

So you got this error, even though your Gemfile bundles mysql2:

!!! Missing the mysql2 gem. Add it to your Gemfile: gem 'mysql2'
Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

or

Please install the mysql adapter: `gem install activerecord-mysql-adapter` (mysql is not part of the bundle. Add it to Gemfile.)

The reason for this confusing error message is probably that your Gemfile says mysql2, but your database.yml still uses the mysql adapter. Change it to use the mysql2 adapter:

development:
  adapter: mysql2
  database: myproject_development
  encoding: utf8
  username: root
  password: secret

Note if you're on an old Rails version

If you're using a Rails version less than 3.1 (e.g. 2.3.x, 3.1.x), you need the mysql2 in a 0.2.x version. Newer versions no longer include the ActiveRecord adapter (which is part of ActiveRecord since Rails .1). So your Gemfile should say:

gem 'mysql2', '~0.2.0'
Posted by Henning Koch to makandra dev (2012-08-07 15:47)