pgsql 允许任意 ip 访问

# 配置文件路径:/var/lib/pgsql/*/data/  或者/etc/postgresql/9.x/main

# (1)修改配置文件 postgresql.conf
$ sudo vim /var/lib/pgsql/*/data/postgresql.conf

# 添加一行或去掉注释修改为:listen_addresses = * 
# 取消被注释的端口(5432)一行

# (2)修改配置文件 pg_hba.conf,在下面添加一行:host  all  all  0.0.0.0/0  md5 
$ sudo vim /var/lib/pgsql/*/data/pg_hba.conf

# TYPE  DATABASE        USER            ADDRESS                 METHOD 
# IPv4 local connections:
host    all             all             127.0.0.1/32             md5
host    all             all             0.0.0.0/0                md5 

# (3)重启数据库
$ systemctl restart postgresql

 

pgsql 允许任意 ip 访问

上一篇:第3章 MySQL的简单操作


下一篇:Ad hoc access to OLE DB provider 'Microsoft.ACE.OLEDB.12.0' has been denied. You must access this provider through a linked server.