
PostgreSQL 数据库安装之后,默认只能本地访问连接,如果其它机器需要远程访问 PostgreSQL 数据库,则需要进行相关配置。
涉及到两个配置文件,都在数据库的 data 目录下:
修改 postgresql.conf 文件
修改:
listen_addresses=’localhost’
为:
listen_addresses=’*’
修改 pg_hba.conf 文件
在 IPv4 local connections: 下面新增一行,
修改:
host all all 127.0.0.1/32 md5
为:
host all all 127.0.0.1/32 md5
host all all 0.0.0.0/0 md5
0.0.0.0/0
表示允许所有 IP 访问。
重启
执行命令:./pg_ctl restart -D DATA 目录