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

duu*_*uug 0 postgresql remote-access postgresql-9.5

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

完成这两件事后,我的 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
Run Code Online (Sandbox Code Playgroud)

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

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

Whi*_*her 5

从您收到的错误可以清楚地看出您在 postgresql.conf 中进行了更改:

listen_addresses = 'localhost'
Run Code Online (Sandbox Code Playgroud)

到:

listen_addresses = '*'
Run Code Online (Sandbox Code Playgroud)

正确。

那么问题就出在 pg_hba.conf 中,你应该有:

host    all         all         192.168.101.20/24    trust
Run Code Online (Sandbox Code Playgroud)

你确定你没有输入类似的内容:

host    all         all         192.168.101.20/trust
Run Code Online (Sandbox Code Playgroud)

或者

host    all         all         192.168.101.20/    trust
Run Code Online (Sandbox Code Playgroud)

或者

host    all         all         192.168.101.20    trust
Run Code Online (Sandbox Code Playgroud)

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

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

问候