psql: 致命错误: 对用户"user1"的对等认证失败

时间:2016-10-14 20:29:25   收藏:0   阅读:2330

操作系统:Debian8

登录pg时可能会有提示错误:

$ psql -U user1 -d exampledb
psql: 致命错误: 对用户"user1"的对等认证失败

打开以下文件,

$ sudo vi /etc/postgresql/9.4/main/pg_hba.conf
# TYPE DATABASE USER ADDRESS METHOD

# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5

将 peer 改为md5:

# TYPE DATABASE USER ADDRESS METHOD

# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5

然后重启服务:

$ sudo service postgresql restart

再登录即可:

$ psql -U user1 -d exampledb

-- End --

原文:http://www.cnblogs.com/ibgo/p/5961849.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!