pg_hba.conf 配置
# TYPE DATABASE USER CIDR-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 md5
host all all 192.168.0.3/16 md5
# IPv6 local connections:
host all all ::1/128 md5
需要注意的是192.168.0.3为当前服务器IP地址,/16为子网掩码即255.255.0.0,子网掩码设置错误可能导致无法连接。
postgresql.conf配置
#---------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#---------------------------------------------------------------------------
listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost', '*' = all
# (change requires restart)
port = 5432 # (change requires restart)