如果 database.yml 不工作,那么也许你应该检查一个 .env 文件。您可以做一些事情来确保 database.yml 文件是 coorect - 以下是默认语法的样子
default: &default
adapter: mysql2
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
username:
password:
host: localhost
# development:
# <<: *default
# database: db/development.sqlite3
development:
adapter: mysql2
encoding: utf8
database:
username:
password:
host: localhost
port: 3306
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
adapter: mysql2
encoding: utf8
database:
username:
password:
host: localhost
port: 3306
production:
adapter: mysql2
encoding: utf8
pool: 10
database:
username:
password:
host: localhost
port: 3306