I\'m having trouble finding a solution to this problem. I\'m getting the error:
Please install the mysql adapter: \'gem install activerecord-mysql-adapter\'
you have mentioned your database.yaml file already has mysql2
.
Its worth checking if you have activerecord-mysql2-adapter
installed.
(Note -mysql2-
)
I never would have believed it but deleting my database.yml file and recreating it actually solved the problem for me too. Thanks Tyler. I spent hours installing and uninstalling different versions of the gems mysql, mysql2, activerecord-mysql-adapter, etc... In the end, my gemfile has
gem 'mysql2', "~>0.3.11"
and my database.yml file has
adapter: mysql2
I am on OSX 10.8, rails 3.2.8, and ruby 1.9.3.
By the way, I experienced the same issues with the mysql2 adapter on my Windows 7 machine. Uninstalling and even deleting the directory for the activerecord-mysql-adapter gem seemed to be critical as well.
You want to install the mysql2 gem.
Really, you should probably add it to your Gemfile
:
gem "mysql2"
And then install your gems with bundler:
bundle install
I just added the following line to my Gemfile an it worked:
gem "mysql"
Before:
source 'https://rubygems.org'
gem "rails", "3.2.16"
gem "jquery-rails", "~> 2.0.2"
gem "coderay", "~> 1.1.0"
gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
gem "builder", "3.0.0"
...
After:
source 'https://rubygems.org'
gem "mysql"
gem "rails", "3.2.16"
gem "jquery-rails", "~> 2.0.2"
gem "coderay", "~> 1.1.0"
gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
gem "builder", "3.0.0"
...
I had the same problem as OP on OSX Lion after upgrading to Rails 3.2. Removing all gems, bundle install, etc did not work. Gemfile and database.yml were correctly specifying mysql2.
In the end, I deleted and recreated my database.yml and everything works again. It was probably a typo or hidden character in the file.
In my case, when I also got this error:
rake aborted! Please install the mysql adapter:
gem install activerecord-mysql-adapter
(mysql is not part of the bundle. Add it to Gemfile.)
After I searched Google and tried many ways, it didn't work. Finally, the answer is
open gemfile
gem 'mysql2', '< 0.3.7'
directly below the gem line for rails.