我知道在 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
数据库.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
我很不擅长做 devop,从前天早上开始我就在和那个问题作斗争,现在它仍然存在,所以如果有人能帮助我解决这个问题,我将不胜感激。
最佳答案
psql 使用本地套接字连接,rails 使用 localhost over TCP/IP。 Local 是可信的,localhost 需要密码(使用 md5)。您可以为您的 rails 用户设置一个 pgpass 文件:http://www.postgresql.org/docs/current/static/libpq-pgpass.html
关于PostgreSQL fe_sendauth : no password supplied,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27419961/