2010-12-09 54 views
21

Im a Rails初學者,並且在Ubuntu 10.10上使用Rails 3。我的database.yml如下。生產數據庫不是由rake db創建的:創建命令

development: 
    adapter: mysql 
    database: project_dev 
    username: root 
    password: rootpassword 
    host: localhost 

# 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: 
    adapter: mysql 
    database: project_test 
    username: root 
    password: rootpassword 
    host: localhost 

production: 
    adapter: mysql 
    database: project_production 
    username: root 
    password: rootpassword 
    host: localhost 

然後我切換到項目文件夾,運行命令:

rake db:create 

但是,只有project_dev和創建project_test數據庫。 project_production數據庫在mysql中不存在。這裏有什麼問題?

請幫助 謝謝

回答

57

也就是說它旨在方式。要創建生產數據庫做:

RAILS_ENV=production rake db:create 

而且,看看rake db:setup將運行任何程序放在db/seeds.rb

5

這是按照@iain的建議設計的。要創建所有數據庫,請運行rake db:create:all

+0

這也將創建開發和測試數據庫。 – Chip 2015-05-17 21:06:46