postgresql 如何使用 postgres 在 heroku 服务器上创建新数据库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4125049/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create new database on heroku server with postgres
提问by Jayashri
I want to create a PostgreSQL database on a Heroku server.
我想在 Heroku 服务器上创建一个 PostgreSQL 数据库。
My database.yml
is
我的database.yml
是
production:
adapter: postgresql
encoding: utf8
database: ddb
username: postgres
port: 5432
password: admin
host: localhost
When I run heroku rake db:create
it gives me the error:
当我运行时,heroku rake db:create
它给了我错误:
mydatabase already exists
(in /disk1/home/slugs/181380_8d7032f_f439-4fe4f5a6-f181-4150-a968-fadcf45f0af5/mnt)
I have tried it for various different database names, but get the same message.
我已经尝试了各种不同的数据库名称,但得到了相同的消息。
How can I resolve this error?
我该如何解决这个错误?
回答by oma
heroku autogenerates database.ymlon the deploy. Reads like: it doesn't matter what you put in your database.yml, which to me is nice, as I can include it in git without worrying about production db passwords.
heroku在部署时自动生成 database.yml。读起来像:你在 database.yml 中放入什么并不重要,这对我来说很好,因为我可以将它包含在 git 中而不必担心生产数据库密码。
You may choose another database by setting the ENV['DATABASE_URL'] (use heroku config:add DATABASE_URL=....
)
您可以通过设置 ENV['DATABASE_URL'] 来选择另一个数据库(使用heroku config:add DATABASE_URL=....
)
Check heroku documentation https://devcenter.heroku.com/articles/ruby-support#build-behavior
检查 heroku 文档 https://devcenter.heroku.com/articles/ruby-support#build-behavior