【问题标题】:Setting up PostgresQL on Heroku Rails 4在 Heroku Rails 4 上设置 PostgresQL
【发布时间】:2015-12-03 10:47:32
【问题描述】:

自从我使用 postgresql 并将应用程序部署到 Heroku 已经有一段时间了,我认为我的设置在某个地方出错了。

我在 Heroku 上创建了我的应用程序,有一个 Hobby Dev 数据库设置 (I ran Heroku run rake db:setup) 设置了我的数据库,但我想知道我的 database.yml 文件中是否有错误

default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: 5

production:
<<: *default
database: my_app_production
username: my_app
password: <%= ENV['MY_APP_DATABASE_PASSWORD'] %>

当我运行heroku run rake db:create 时,我得到了

 FATAL:  permission denied for database
 DETAIL:  User does not have   CONNECT privilege.

Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "database"=>"databaseName", "username"=>"userName", "password"=>"password", "port"=>5432, "host"=>"hostNamehere"}

我已经使用heroku config:set设置了数据库密码

我错过了什么?

谢谢

【问题讨论】:

  • 你给postgres设置密码了吗heroku config:set MY_APP_DATABASE_PASSWORd='password'
  • 是的,我已经这样做了,但我会在问题中更新它以避免混淆,谢谢
  • 你能把你得到的日志放上去吗.. 或者试试这个。*.com/questions/20293895/…

标签: ruby-on-rails ruby postgresql heroku


【解决方案1】:

Heroku 会忽略您的 database.yml 配置,它们会在您部署应用程序时生成一个,并且它们还负责数据库的创建。 您需要做的只是heroku run rake db:migrateheroku run rake db:seed,以防您需要为数据库播种。

【讨论】:

  • 那让一切变得美好而简单:-) 谢谢
  • 因为我需要等待 7 分钟才能接受 :)