新建服务器出现错误 Peer authentication failed for user "postgres" 的解决办法
Posted on 2018-11-07 16:35 很聪明的Joy 阅读(2524) 评论(0) 收藏 举报用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
                    
                
                
            
        
浙公网安备 33010602011771号