我正在尝试远程访问 postgres 数据库,但是修改 pg_hba.conf 和 postgresql.conf 后 postgres 服务不会启动

I'm trying to access a postgres db remotely, but the postgres service won't start after modifying pg_hba.conf and postgresql.conf

我读到要启用对 postgres 数据库的远程访问,必须修改 pg_hba.conf 以添加客户端身份验证记录,并更改 postgresql.conf 中的监听地址。详情为 here.

完成这两件事后,我的 postgres 服务无法启动。这是我的日志:

2016-03-14 20:10:48 WET LOG:  invalid IP mask "trust": Unknown host
2016-03-14 20:10:48 WET CONTEXT:  line 81 of configuration file "C:/Program Files/PostgreSQL/9.5/data/pg_hba.conf"
2016-03-14 20:10:48 WET FATAL:  could not load pg_hba.conf

第 81 行是我添加客户端身份验证记录的地方。

当我尝试启动服务时,使用本地系统帐户是否足够,还是需要登录?我是否需要在 postgresql 应用程序中配置具有组角色和登录角色的内容?最后,如果有所不同,数据库将托管在 Google Compute Engine 实例上。

从您收到的错误可以看出,您在 postgresql.conf 中所做的更改来自:

listen_addresses = 'localhost'

至:

listen_addresses = '*'

正确。

那么问题就在 pg_hba.conf 你应该有的地方:

host    all         all         192.168.101.20/24    trust

你确定你没有放这样的东西吗:

host    all         all         192.168.101.20/trust

host    all         all         192.168.101.20/    trust

host    all         all         192.168.101.20    trust

24是IP掩码,就是过滤多少ip。 24 位掩码意味着任何 ip 为 192.168.101.xxx 的主机都将被接受。 32掩码将限制对单个ip的访问。

系统似乎在说它发现信任作为 ip 掩码...

此致