postergresql允许其它主机远程连接

时间:2024-01-16 12:22:20

1.pg_hba.conf中添加listen_addresses = '*'

#vim /usr/local/postgresql/data/pg_hba.conf

#listen_addresses = 'localhost' # what IP address(es) to listen on;
listen_addresses = '*'

2.postgresql.conf中添加host all all 192.168.0.1/24 trust,表示192.168.0.1~192.168.0.254的IP允许连接

#vim /usr/local/postgresql/data/postgresql.conf

# IPv4 local connections:
host all all 127.0.0.1/32 trust
host all all 192.168.0.1/24 trust