0

Trying to run the database in RoR i have this error

Couldn't create database for {"adapter"=>"sqlite3", "pool"=>5, "timeout"=>5000, "database"=>"db/test.sqlite3"}
rake aborted!
Gem::LoadError: 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).  

but when i do gem list i get that i have mysql2 (0.4.1)

How can i fix this? and also, why does this happens?

3

3 Answers 3

1

Check /config/database.yml file

Probably your file contains something like this:

development:
  adapter: sqlite3
  pool: 5
  timeout: 5000
  database: db/development.sqlite3

Change sqlite to mysql and add login settings, also check environment (development, production or test)

0

you need to run bundle install as you have already added the gem in the Gemflle.Also you need to setup mysql and other libs before installing it.

1
  • Without bundle install, will it show in the gem list?
    – Abhi
    Oct 16, 2015 at 12:53
0

You should include the mysql2 gem into your gemfile and run 'bundle install'.

Also your config/database.yml should look something like the below

           development:
              adapter: mysql2
              encoding: utf8
              database: my_db_name
              username: root
              password: my_password

Here the username and password will be the one you gave at the time of configuring the mysql inyour system

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.