在try 通过ahoy_matey
GEM创建到数据库blazer
的连接时,从Rails应用程序内部,配置需要连接到Postgres,首先try 直接连接,而不是通过ENV变量
data_sources:
main:
# url: <%= ENV["BLAZER_DATABASE_URL"] %>
url: "postgres://deploy_root@111.222.333.44:5432/databasename_production"
语法应该在哪里
ENV["BLAZER_DATABASE_URL"] = "postgres://user:password@hostname:5432/databasename_production"
个
对于具有超级用户权限的postgres,存在用户deploy_root
,但是,错误地填写了database.yml
:
production:
<<: *default
database: databasename_production
username: deploy_root
password: <%= ENV["DATABASENAME_DATABASE_PASSWORD"] %>
其中控制台确认
> ENV["DATABASENAME_DATABASE_PASSWORD"]
=> nil
the application runs as expected, connecting to the database. The replication of those connections for blazer is however failing as such:
"postgres://deploy_root@111.222.333.44:5432/databasename_production"
ActiveRecord cannot connect
`ActiveRecord::ConnectionNotEstablished (could not connect to server: Connection refused
Is the server running on host "111.222.333.44" and accepting
TCP/IP connections on port 5432?`
Blazer需要设置DATA_SOURCES/Main(遗憾的是它没有依赖于Rails应用程序连接的机制……)这就提出了如何连接的问题,因为密码不确定(用于此服务器上的另一个应用程序).
• how to recover the encrypted password for the postgres USER?
• if it is nil
how to establish the connection?