rake db:migrate让rake中止了

时间:2013-09-17 02:54:29

标签: mysql ruby-on-rails ruby sqlite

我从演示中学习rails, 原始database.yml

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

因此,此演示使用sqlite作为数据库,但我想更改为mysql,因此我将database.yml更改为:

adapter: mysql2
database: jobs_test
server: localhost
username: root
password: "1234"
pool: 5
timeout: 5000
encoding: utf8

当我跑

rake db:migrate

然后我收到了错误:

rake aborted!
Please install the sqlite3 adapter: `gem install activerecord-sqlite3-adapter`  
(sqlite3 is not part of the bundle. Add it to Gemfile.)

所以,我已将适配器更改为mysql2,为什么让我安装sqlite3 adapter

2 个答案:

答案 0 :(得分:0)

确保使用嵌套在development:下的配置值正确缩进database.yml,如下所示:

development:
  adapter: mysql2
  database: jobs_test
  server: localhost
  username: root
  password: "1234"
  pool: 5
  timeout: 5000
  encoding: utf8

您的原始示例未显示正确的缩进。

当然,如果您还没有这样做,请务必添加:

gem 'mysql2'

到Gemfile并运行:

bundle install
rake db:migrate

答案 1 :(得分:0)

您是否删除或仅更新了database.yml中的测试和生产配置?