简体   繁体   中英

rake db:migrate got rake aborted

I study rails from a demo, the original database.yml is

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

so this demo use sqlite as database,but I want to change to mysql ,so I change database.yml as:

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

when I run

rake db:migrate

then I got the error:

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

so,I have changed the adapter to mysql2 ,why it let me install sqlite3 adapter ?

Make sure your database.yml is indented properly with the config values nested under development: like this:

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

You original example doesn't show proper indentation.

And of course if you haven't done so already, make sure to add:

gem 'mysql2'

to Gemfile and run:

bundle install
rake db:migrate

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM