首页 > 解决方案 > Postgres 远程连接 - Windows 服务器

问题描述

我在pg_hba.conf. Postgres 安装在 Windows 服务器上。

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
#host   all             all             myip            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
host    replication     all             127.0.0.1/32            md5
host    replication     all             ::1/128                 md5

我想只允许来自另外一个公共 IP 地址的连接。我怎样才能做到这一点?一旦我启用了上面的线路 IP: Postgres 就不会启动。

寻求一些指导。

标签: postgresqlremote-accesspg-hba.conf

解决方案


要打开端口 5432,请编辑您的/Program Files/PostgreSQL/10/data/postgresql.conf并更改

# Connection Settings -

listen_addresses = '*'          # what IP address(es) to listen on;

/Program Files/PostgreSQL/10/data/pg_hba.conf

# IPv4 local connections:
host    all             all             0.0.0.0/0           md5

现在重述 Postgres 服务器使用 cmd

pg_ctl -D "C:\Program Files\PostgreSQL\10\data" restart

推荐阅读