PostgreSQL fe_sendauth : no password supplied

标签 postgresql unix ansible

我知道在 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/

相关文章:

python - 无法在 Django 上使用 SSL 连接到 PostgreSQL

带别名的 SQL 汇总

linux - 仅当变量包含特定字符串时才运行 Ansible 任务

PostgreSQL:更改枚举类型的列

java - 如何让 Spring Boot 自动重新连接到 PostgreSQL?

r - 如何设置 R 从没有 bin 或 root 访问权限的目录运行?

c++ - 使用 unix 终端运行 c++ 程序

bash - 使用 scp 将文件从一台服务器复制到另一台服务器时发送密码

Ansible:如何通过在主机上附加文件的任务实现幂等性(不恢复到初始状态)

ansible - 无法从数据库中获取 gitlab runners 注册 token