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?

Limon Monte
  • 52,539
  • 45
  • 182
  • 213
  • 1
    Why your adapter is `sqlite3`, change it to `mysql2` – Abhi Oct 16 '15 at 12:51
  • 1
    Hi, what's your rails version. I think it's rails bug, Check this link http://stackoverflow.com/questions/32457657/rails-4-gemloaderror-specified-mysql2-for-database-adapter-but-the-gem-i – Padhu Oct 16 '15 at 12:52
  • You might wanna check it here: http://stackoverflow.com/questions/22932282/gemloaderror-specified-mysql2-for-database-adapter-but-the-gem-is-not-loade – Amir Hassan Azimi Oct 16 '15 at 13:48

3 Answers3

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)

General Failure
  • 2,421
  • 4
  • 23
  • 49
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.

Milind
  • 4,535
  • 2
  • 26
  • 58
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

Kwaghray
  • 39
  • 2
  • 9