USEGEAR

导航

远程连接到轻量应用服务器PG数据库

不建议这样做,但是开发时方便需要。进入正题。

PG是不支持远程连接的,需要连接直接该参数。

在其data目录里,有二个配置文件:

  1. pg_hba.conf:配置数据库的访问权限
  2. postgresql.conf:配置数据库服务的相关参数
#------------------------------------------------------------------------------
# pg_hba.conf: #------------------------------------------------------------------------------
# IPv4 local connections: host all all
127.0.0.1/32 md5 host all all 0.0.0.0/0 md5 # IPv6 local connections: host all all ::1/128 md5 #------------------------------------------------------------------------------ # postgresql.conf:
#CONNECTIONS AND AUTHENTICATION #------------------------------------------------------------------------------ # - Connection Settings - listen_addresses
= '*' # what IP address(es) to listen on; # comma-separated list of addresses; # defaults to 'localhost'; use '*' for all # (change requires restart) port = 5432 # (change requires restart)

别问我为什么这样改,洒家不懂。依葫芦画瓢管用就行。

然后重启PG服务。

 

posted on 2022-04-08 11:18  USEGEAR  阅读(222)  评论(0编辑  收藏  举报