1.更改pg_hba.conf,配置用户的访问权限
vim 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 trust
host all all 192.168.1.0/24 md5
host all all 0.0.0.0/0 md5 # 增加这一行
# IPv6 local connections:
host all all ::1/128 trust
2.更改postgresql.conf
vim postgresql.conf
listen_address = '*' #更改这一行
3.重启
su - postgres
pg_ctl restart