- 转到此/etc/postgresql/9.x/main/并打开pg_hba.conf文件
就我而言:
$> sudo nano /etc/postgresql/9.3/main/pg_hba.conf
- 用md5替换对等
因此,它将更改为:
通过Unix域套接字本地所有postgres对等体进行数据库管理登录
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 md5
这个:
通过Unix域套接字本地所有postgres md5进行数据库管理登录
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
然后重启pg服务器:
$> sudo服务postgresql重新启动
以下是用于与postgres连接的方法的列表:
# METHOD can be "trust", "reject", "md5", "password", "gss", "sspi",
# "krb5", "ident", "peer", "pam", "ldap", "radius" or "cert". Note that
# "password" sends passwords in clear text; "md5" is preferred since
# it sends encrypted passwords.
注意:如果您还没有创建postgres用户。创建该文件,现在您可以使用该用户凭据访问postgres服务器。
提示:如果postgres重新启动后仍然无法使用,请关闭终端,然后再次打开。