1、报错信息
could not connect to server: Connection refused
Is the server running on host host.domain.com and accepting
TCP/IP connections on port 5432?
2、解决方法
1、添加pg远程访问权限
vim \data\pg_hba.conf
2、添加ip
# 在 TYPE DATABASE USER ADDRESS METHOD 下方添加
host all all / md5
注:IP-address 代表允许连入的 ip, 而 mask-length 代表子网掩码长度,最小值是 0, 最大值是 32。
若要设定全部开放,则可设定为:
host all all 0.0.0.0/0 md5
若要设定允许连入的网址为:192.168.3.* ,则可设定为:
host all all 192.168.3.0/24 md5
3、修改listen_addresses
设置\data\postgresql.conf 中的 listen_addresses 与 port 设定与以 下相同:
listen_addresses = '*'
port = 5432
4、重启pg数据库
pg_ctl start [-w] [-s] [-D datadir] [-l filename] [-o options] [-p path]
pg_ctl stop [-W] [-s] [-D datadir] [-m s[mart] | f[ast] | i[mmediate] ]
pg_ctl restart [-w] [-s] [-D datadir] [-m s[mart] | f[ast] | i[mmediate] ] [-o options]
pg_ctl restart -D /data