重启 postgres 服务器在日志文件中为用户 postgres 写入致命错误密码验证

Restart postgres server writes fatal error password authentication for user postgres in logfile

当我使用 sudo service postgresql restart 重新启动 postgresql 服务器时,一切都按预期进行。

但是日志文件 /var/log/postgresql/postgresql-9.3-main.log 显示发生了致命错误。

2016-12-09 11:50:26 CET LOG:  MultiXact member wraparound protections are now enabled
2016-12-09 11:50:26 CET LOG:  autovacuum launcher started
2016-12-09 11:50:26 CET LOG:  database system is ready to accept connections 
2016-12-09 11:50:26 CET FATAL:  password authentication failed for user "postgres"
2016-12-09 11:50:26 CET DETAIL:  Connection matched pg_hba.conf line xx: "local   all             postgres                                md5"
2016-12-09 11:50:27 CET FATAL:  password authentication failed for user "postgres"

我确实使用安全密码设置了 postgres 超级用户 postgres。 我可以使用

登录
psql -U postgres

但是 UNIX 用户 postgres 也设置了登录名 shell 和密码。所以我通过在 /etc/passwd 中设置 /usr/sbin/nologin 来锁定该用户。 我不能再 su 进入 UNIX postgres 用户,但是

sudo -u postgres psql postgres

可以登录数据库。

重新启动服务器仍然显示相同的错误消息。

pg_hba.conf 中,postgresall 的方法设置为 md5

我真的不明白服务器在抱怨什么,因为可以建立连接并且我可以登录。

非常感谢!

要么在pg_hba.conf用户"postgres"中设置为"peer"身份验证,要么添加到postgres $HOME目录文件.pgpass,内容为localhost:*:*:postgres:password。文件必须有 mod 600.