mysql - rake 数据库 :migrate got rake aborted

标签 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适配器

最佳答案

确保您的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/

相关文章:

ruby-on-rails - 使用单表继承更改 Rails 中 ActiveRecord 类的类型

ruby-on-rails - UPS 的 Active_Shipping 协议(protocol)费率 - Ruby on Rails

ruby - 计算 Stripe taxamo价格(含税)的最佳方法

ruby-on-rails - 为什么 pp-adaptive 不接受我的退款金额?

sql - 在数据库中,如果你只需要年和月,你会使用日期字段还是年月字段?

mysql - 当两年都存在发票时,按年份获取总计

css - act_as_taggable_on 模板/css : Rails tag cloud

ruby-on-rails - rescue_from ActionController::RoutingError 不起作用

Mysql触发器: check value is actually set in before insert trigger

mysql - Orchard 中的后台运行功能