[英]rails is not using the configuration set on database.yaml
這是我的database.yml
production:
adapter: mysql2
encoding: utf8
database: testing
pool: 5
username: ubuntu
host: 127.0.0.1
當我運行rake db:setup
我得到了:
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "database"=>"testing", "pool"=>5, "username"=>"ubuntu", "host"=>"127.0.0.1"}
-- create_table("documents", {:force=>:cascade})
rake aborted!
Mysql2::Error: Access denied for user ''@'localhost' to database 'testing'
為什么不使用我的用戶名和主機? 而是顯示'' @ 'localhost'
我認為,database.yml配置用於生產環境,但是您可以在開發環境上運行它。 您可以使用'RAILS_ENV =開發rake db:setup'或'RAILS_ENV = test rake db:setup'另外一件事,數據庫應該由具有root權限的mysql用戶創建。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.