TJ Sherrill
TJ Sherrill

Reputation: 2645

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

I am running a rails3 app on Dreamhost: not the best call but I need it operational before I can pitch migrating to Heroku.

I am using rails 3.2.1, and ruby 1.8.7 with

gem 'mysql2', '~> 0.2.7'

in my Gemfile...

I get the following error when I deploy and reload:

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

I have tried gem 'mysql2', gem 'mysql2', '< 0.3' and get the exact same issue.

Any other ideas?

Upvotes: 4

Views: 13114

Answers (4)

zanguinette
zanguinette

Reputation: 21

I had the same problem and after checking if you have in database.yml that you have adapter:mysql2 you should check if you have the gem of mysql loaded.

in your Gemfile you should have the line : gem "mysql2" and not other database like sqlite3 which was my case.

Hope this helps.

Upvotes: 2

Andy
Andy

Reputation: 1

I get into the same situation of trying to set up mysql with Ruby on Rails for my Windows Vista platform installed with MySQL 5.5 and Rails Installer for Ruby 1.93.

After getting the adapter and connector for mysql2, I still get this error message : "rubygems_integration.rb:143:in block in replace_gem': Please install the mysql2 adapter:gem install activerecord-mysql2-adapter` (mysql2 is not part of the b undle. Add it to Gemfile.) (LoadError)"

I checked the my gem directory "Ruby1.9.3\lib\ruby\gems\1.9.1\gems" and see both activerecord-mysql2-adapter-0.0.3 and mysql2-0.3.11-x86-mingw32 are there and the database.yaml file is correctly updated.

The missing piece is here:http://www.mohanarun.com/how-to-install-mysql-adapter-ruby-gem-in-windows/

After restarting the MySQL server and update the gem file as stated in the above URL. It works.

I hope this will work for you.

Upvotes: 0

user471245
user471245

Reputation: 191

First try adding config.assets.initialize_on_precompile = false to your application.rb.

Then make sure your DATABASE_URL var starts with mysql2:// instead of mysql://

Upvotes: 10

xkickflip
xkickflip

Reputation: 768

In general when rails is trying to be helpful it will try to generate the name of an adapter gem based on whatever you have in your database.yml. If that gem doesn't exist it's a good indication that something with the adapter line is wrong

for mysql2 the adapter type needs to be mysql2 as well

database.yml

adapter: mysql2

Upvotes: 5

Related Questions