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


用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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM