PostgreSQL中允许哪些IP的机器能够访问数据库是由配置文件pg_hba.conf控制的,通过配置该文件,能够指定哪些ip可以访问,哪些ip不可以访问,以及访问的认证方式。hba是host-based authentication的缩写。
原文地址:
https://mytecdb.com/blogDetail.php?id=77
initdb在初始化数据目录的时候,会生成一个默认的pg_hba.conf文件。pg_hba.conf文件格式由多条记录组成,每条记录占一行,#开头为注释,这些记录控制着客户端访问数据库的权限和认证方式。
先看一个PostgreSQL默认生成的pg_hba.conf文件示例,如下:
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user w