Peer authentication failed for user "postgres" 的解决办法

1. Peer authentication 是默认的配置,如果你的计算机用户名和你的postgres数据库名是一样的话,那么就不会出现此错误,不需要为你的数据库设置密码。

2. md5 authentication,它需要密码。

而我的计算机用户名和我的数据库名不一致,所以需要把Peer authentication改成md5 authentication,然后给数据库设置密码。

在哪里改?

执行命令:  vi /var/lib/pgsql/10/data/pg_hba.conf 

找到下面的一行:

local   all             postgres                                peer

改成

local   all             postgres                                md5

然后systemctl restart postgresql-10

猜你喜欢

转载自blog.csdn.net/u011365831/article/details/79508027
今日推荐