# 配置文件路径:/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