简体   繁体   English

如何使用postgres在heroku服务器上创建新数据库

[英]How to create new database on heroku server with postgres

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? 我该如何解决这个错误?

heroku autogenerates database.yml on the deploy. heroku在deploy上自动生成database.yml 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. 读取如下:你放在database.yml中的内容并不重要,这对我来说很好,因为我可以将它包含在git中,而不必担心生成db密码。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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