且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PG::ConnectionBad: 致命:用户“用户名"错误的对等身份验证失败

更新时间:2021-11-13 08:31:54

首先,找到你的pg_hba.conf:

First, to find your pg_hba.conf :

sudo find/-name "pg_hba.conf"

在我的系统上是/var/lib/pgsql/data/pg_hba.conf.

It is /var/lib/pgsql/data/pg_hba.conf on my system.

确保在 pg_hba.conf 中更改这一行:

Make sure to change this line in pg_hba.conf :

local all all local

到:

local all all md5

最后,重启 postgresql :

Lastly, restart postgresql :

OS X:

launchctl 卸载 ~/Library/LaunchAgents/org.postgresql.postgres.plist

launchctl load ~/Library/LaunchAgents/org.postgresql.postgres.plist

系统化:

sudo systemctl restart postgresql.service

SysVinit:

sudo service postgresql restart