FATAL: Peer authentication failed for user 'XXX'
- 操作系统:CentOS 7.5
- PostgreSQL版本:10.4
\c - XXX 切换user时,提示FATAL: Peer authentication failed for user 'XXX' 原因是PostgreSQL配置文件/var/lib/pgsql/10/data/pg_hba.conf中,local的METHOD为peer,
# TYPE DATABASE USER ADDRESS METHOD# "local" is for Unix domain socket connections onlylocal all all peer
而正如提示信息,“Peer authentication failed for user 'XXX'”,所以把peer改成md5后,重启服务即可。
# TYPE DATABASE USER ADDRESS METHOD# "local" is for Unix domain socket connections onlylocal all all md5
重启服务命令:systemctl restart postgresql-10