简体   繁体   English

无法将localhost连接到heroku数据库

[英]Can't connect localhost to heroku database

I am trying to get a rails app to work with heroku but I am doing something wrong. 我正在尝试使用rails应用程序与heroku一起工作,但我做错了什么。

Database.yml database.yml的

   development:
    adapter: postgresql
    encoding: unicode
    database: (heroku db)
    user: (heroku db_user)
    pool: 5
    password: (heroku db_pass)

If I enter the information from my heroku database I get: 如果我从我的heroku数据库输入信息,我得到:

PG::ConnectionBad FATAL: password authentication failed for user PG :: ConnectionBad FATAL:用户密码验证失败

I am not rails guy, But this is something that i have done just now on my spring app, I wanted to connect my localhost development to heroku db.. I got db info from this: 我不是铁杆人,但这是我刚刚在我的春季应用程序上完成的事情,我想将我的localhost开发连接到heroku数据库..我从这里得到了数据库信息:

heroku pg:credentials DATABASE

then I have passed params.. But I found that to connect remote heroku db, I needed to add this to my connection params.. 然后我已经通过params ..但我发现要连接远程heroku数据库,我需要将它添加到我的连接参数..

ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory

I guess, you also need to specify the host and port. 我想,你还需要指定主机和端口。 To find out the host try running this command: 要查找主机,请尝试运行此命令:

$ heroku config | grep HEROKU_POSTGRESQL

You should see something like 你应该看到类似的东西

HEROKU_POSTGRESQL_RED_URL: postgres://user3123:passkja83kd8@ec2-117-21-174-214.compute-1.amazonaws.com:6212/db982398

if you already added the PostgreSQL add-on. 如果你已经添加了PostgreSQL附加组件。 More on this read here . 更多关于此处的内容

Then add the host and port info to your configuration: 然后将主机和端口信息添加到您的配置中:

development:
  ...
  host: ec2-117-21-174-214.compute-1.amazonaws.com
  port: 6212
  ...

But do remember that it's a bad idea to work with the production database from your local dev machine, unless you really know what you are doing. 但请记住,从本地开发机器使用生产数据库是个坏主意,除非你真的知道自己在做什么。

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

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