我最近在客户的 CentOs 机器上建立了一个 PostgreSQL 数据库。到目前为止,远程访问受到限制。
现在我尝试为我们打开远程连接,在pg_hba.conf
.
host all all x.x.x.x/x trust
连接很好,我们只需提供用户名就可以连接数据库。连接时未提供密码。
现在我们只需要限制对有效凭据的访问。
为此,我已将条目更改为
host all all x.x.x.x/x md5
并且重启了postgresql服务(我已经重启了多次)。如果我们尝试在没有密码或密码错误的情况下进行连接,则数据库已连接。
我想我做错了什么pg_hba.conf
。任何指示出了什么问题?
以下是该文件的内容:
# 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 ident
# IPv6 local connections:
host all all ::1/128 ident
host all all 0.0.0.0/0 trust
# IPv4 remote connections:
host all all x.x.x.x/x md5
host all all x.x.x.x/x md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 ident
#host replication postgres ::1/128 ident