postgresql Postgres:缺少或错误的 pg_hba.conf 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/745019/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 23:41:15  来源:igfitidea点击:

Postgres: missing or erroneous pg_hba.conf file

postgresqlconfiguration

提问by Lancelot

I have 2 machines sitting on my desk and connected to the same IP network. I'm trying to connect an application from one machine to the postgres database on the other. At first the host with the application on it was giving me the PSQLException:

我有两台机器坐在我的桌子上并连接到同一个 IP 网络。我正在尝试将应用程序从一台机器连接到另一台机器上的 postgres 数据库。起初,带有应用程序的主机给了我 PSQLException:

FATAL: no pg_hba.conf entry for host "192.168.1.18", user "user1", database "test", SSL off

So I edited my pg_hba.conf file to accept the IP address: 192.168.1.18, by adding the line below at the end of the file:

所以我编辑了我的 pg_hba.conf 文件以接受 IP 地址:192.168.1.18,通过在文件末尾添加以下行:

host    pnp         all         192.168.1.18      trust

Then I got another type of error message:

然后我收到了另一种类型的错误消息:

FATAL: missing or erroneous pg_hba.conf file

Is there anything I'm missing here?

有什么我在这里想念的吗?

Thanks, Lancelot

谢谢,兰斯洛特

回答by David Schmitt

You have to specify the netmask of the host too. So either "192.168.1.18/32" or "192.168.1.18 255.255.255.255" instead of the bare IP address.

您还必须指定主机的网络掩码。所以无论是“ 192.168.1.18/32”还是“ 192.168.1.18 255.255.255.255”而不是裸IP地址。

See the pg_hba.conf filechapter in the online manual for details.

有关详细信息,请参阅在线手册中的 pg_hba.conf 文件章节。