2015-10-16 73 views
0

试图运行RoR中的数据库中,我有这个错误回报率数据库错误

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). 

但是当我做宝石列表,我感到我有mysql2 (0.4.1)

我怎样才能解决这个问题?还有,为什么会发生这种情况?

+1

为什么你的适配器是'sqlite3' ,将其更改为'mysql2' – Abhi

+1

嗨,你的rails版本是什么。我认为这是轨道bug,检查此链接http://stackoverflow.com/questions/32457657/rails-4-gemloaderror-specified-mysql2-for-database-adapter-but-the-gem-i –

+0

你可能想检查它这里:http://stackoverflow.com/questions/22932282/gemloaderror-specified-mysql2-for-database-adapter-but-the-gem-is-not-loade –

回答

0

您需要运行bundle install,因为您已经在Gemflle中添加了该宝石。您还需要在安装之前设置mysql和其他库。

+0

没有'捆绑安装',它会显示在宝石清单? – Abhi

+0

更新您的database.yml ....运行捆绑安装 – Milind

1

检查/config/database.yml文件

也许你的文件中包含这样的事情:

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

变化sqlitemysql并添加登录设置,还要检查环境(开发,生产或测试)

0

你应该在你的gemfile中包含mysql2 gem并运行'bundle install'。

而且你config/database.yml应该看看下面

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

这里类似的用户名和密码会被你给在配置MySQL的inyour系统时的一个