我通过演示学习 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适配器
?
最佳答案
确保您的database.yml与嵌套在development:
下的配置值正确缩进,如下所示:
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
关于mysql - rake 数据库 :migrate got rake aborted,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18840571/