mysql2 gem installed fine but still getting "Please install the myslq2 adapter..." when running "rake db:migrate"

robertwbradford picture robertwbradford · May 6, 2011 · Viewed 15.2k times · Source

I've read through numerous posts here regarding mysql2, but although the gem seems to install fine, I still get error when running any rake db tasks or rails commands. In my Gemfile:

source 'http://rubygems.org'

gem 'rails', '3.0.7'
gem 'mysql2'

On my remote server I ran the following:

$ bundle install
...
Using mysql2 (0.2.7)
...
Using rails (3.0.7)
...
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

$ rake db:schema:load
(in ...)
rake aborted!
Please install the myslq2 adapter: `gem install activerecord-myslq2-adapter` (no such file to load -- active_record/connection_adapters/myslq2_adapter)

$ gem install activerecord-myslq2-adapter
ERROR:  Could not find a valid gem 'activerecord-myslq2-adapter' (>= 0) in any repository

$ gem install mysql2
Building native extensions.  This could take a while...
Successfully installed mysql2-0.3.2
1 gem installed
Installing ri documentation for mysql2-0.3.2...
Enclosing class/module 'mMysql2' for class Result not known
Installing RDoc documentation for mysql2-0.3.2...
Enclosing class/module 'mMysql2' for class Result not known

$ rake db:schema:load
(in ...)
rake aborted!
Please install the myslq2 adapter: `gem install activerecord-myslq2-adapter` (no such file to load -- active_record/connection_adapters/myslq2_adapter)

Is there something else I am missing? Thank you.

Answer

robertwbradford picture robertwbradford · May 9, 2011

This is embarrassing, but for anyone else who might be having the same problem:

Make sure that your database.yml file has all the correct spellings and no transposed Ls or Qs:

# Correct
development:
  adapter: mysql2

And NOT:

# Incorrect
development:
  adapter: myslq2

Notice the last line on my OP was complaining about the missing myslq2 adapter. Perhaps someone could create a clone of that project with the name myslq2 just in case :)