pgadmin3 新建服务器出现错误 Peer authentication failed for user "postgres" 的解决办法

来源:互联网 发布:疯狂java讲义 下载 编辑:程序博客网 时间:2024/06/09 20:53

用pgadmin3 新建服务器出现错误 Peer authentication failed for user "postgres"

在stackoverflow上找到答案,出现此错误的原因是:

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

还有一种md5 authentication,它需要密码。

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

在哪里改?

/etc/postgresql/9.3/main/pg_hba.conf

执行命令 

找到下面的一行:

local   all             postgres                                peer

改成

local   all             postgres                                md5

然后restart postgresql server

sudo service postgresql restart



0 0