Postgres pg_hba.conf

7

我的一个客户正在设置服务器,安装了postgres后,当我们运行服务器时遇到下面的错误。我Google了一下,有几个解决方案可用,但都没有对我起作用,你能看看是什么情况吗?

Status: 500 Internal Server Error
FATAL:  no pg_hba.conf entry for host "127.0.0.1", user "syr_admin", database     "allprosh_production", SSL off

我的pg_hba.conf文件:

local all  all      md5
host samerole all  127.0.0.200   255.255.255.255   pam  pamservice=postgresql_cpses
host samerole all  127.0.0.1   255.255.255.255   md5
local all postgres        md5
host all postgres  127.0.0.1   255.255.255.255   md5
local   all     all     trust  

提前致谢。
4个回答

7

我自己想通了,尽管花费了很长时间。解决方案很简单,只需要在pg_hba.conf文件中为该特定用户添加一条条目即可。这是我所做的:

local all syr_admin  md5
host all syr_admin 127.0.0.1   255.255.255.255   md5

希望这能帮助其他人... :-)


3
我认为正确的配置是:
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
host    all             all             0.0.0.0/0               md5

如果您想使用其他网络连接,请使用以下方法:

host    all             all             network address/32            md5

以两个八位字节的192.159.0.0为例


2

我在这里回复是因为我无法评论你的解决方案。

不一定要仅将条目添加到特定用户。您可以使用数据库或全部替换选项"samerole"。

我看到您有两行代码互相冲突。

local all  all      md5
local   all     all     trust  

在这种情况下,最后一行胜出,因此在访问方法上添加意外行为时要小心。如果您想在本地询问宇宙密码,必须删除最后一行。
希望这有所帮助!

0

对于使用用户postgres在PostgreSQL上的本地身份验证,您的hba.conf必须有以下行:

# IPv6 local connections:
host    all             postgres             ::1/128             trust

为了确保,您可以添加另一行:

# IPv4 local connections:
host    all             postgres          127.0.0.1/32           trust

注意:您可以将身份验证方法从trust更改为md5。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接