【发布时间】:2019-06-04 00:37:19
【问题描述】:
我知道 SO 上有成千上万个类似这样的问题,但我都看过了,但我仍然无法解决我的问题。
我正在使用 ansible 做所有事情,所以它非常自动化,但无论如何,这是我的文件:
pg_hba.conf
local all all trust
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
host all all 10.11.12.0/24 md5
database.yml
production:
database: my_db
adapter: postgresql
host: localhost
username: deploy
encoding: unicode
min_messages: WARNING
template: template0
我在我的系统中创建了一个deploy 用户(和没有设置密码的 postgres 用户)。现在,虽然我完全可以使用psql -d my_db(在服务器上)从bash 登录postgres,但我无法使用我的rails 应用程序连接到数据库。运行 rake db:migrateMigration 给了我
PG::ConnectionBad: fe_sendauth: no password supplied
我在做一个开发者方面非常糟糕,我从前天早上开始就在与这个问题作斗争,它仍然存在,所以如果有人可以帮助我解决这个问题,我将不胜感激。
【问题讨论】:
-
psql 使用本地套接字连接,rails 使用 localhost over TCP/IP。本地受信任,localhost 需要密码(使用 md5)。你可以为你的 Rails 用户设置一个 pgpass 文件:postgresql.org/docs/current/static/libpq-pgpass.html
-
是的,就是这样!我不知道 rails 连接到 postgres 的方式与用户不同。谢谢!请将其添加为答案,以便我将其标记为已接受:)
标签: postgresql unix ansible