Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql Postgres是否忽略了;“信托”;在pg_hba.conf文件中?_Postgresql - Fatal编程技术网

Postgresql Postgres是否忽略了;“信托”;在pg_hba.conf文件中?

Postgresql Postgres是否忽略了;“信托”;在pg_hba.conf文件中?,postgresql,Postgresql,我的pg_hba.conf文件中有以下几行: host all all 127.0.0.1/32 trust host all all ::1/128 trust host all all localhost trust 我重新开始了博士后课程。当我在命令行连接时,一切都按预期工作: $ psql -U me -W P

我的
pg_hba.conf
文件中有以下几行:

host    all         all         127.0.0.1/32         trust
host    all         all         ::1/128              trust
host    all         all         localhost            trust
我重新开始了博士后课程。当我在命令行连接时,一切都按预期工作:

$ psql -U me -W
Password for user me: # I can type any password and it will work
psql (9.5.7)
Type "help" for help.

me=# 
但是,当我通过软件库(节点库
pg
,通过库
knex
)连接时,我得到一个错误:

password authentication failed for user "me"
我并不是专门寻找修复方法,我只是想了解这是如何可能的。如果我只是告诉Postgres要相信任何人,我怎么还能得到认证失败的错误呢?我的
pg_hba.conf
条目是否有问题,或者Postgres只是在某些情况下选择忽略它们,或者

编辑


如果有帮助,我的程序用于连接的数据库连接URL是:
postgres://localhost:5432/mydb

当您执行
psql-U me-h localhost
时,psql无法连接,因为它不知道要连接到哪个数据库

解决方案是
psql-U me-h localhost-d数据库\U name


希望这有帮助。

你能看看日志吗?(它可能包含关于库实际使用的IP的提示;这可能不是您所期望的)不幸的是,除了错误消息和无用的堆栈跟踪之外,没有任何记录。但是,如果我理解正确,我的库可能以某种方式连接,而不是
127.0.0.1/32
::1/128
localhost
,这将导致它不符合我的规则,从而解释它们不工作的原因。。。是这样吗?如果是这样,有没有办法在
pg_hba.conf
中定义一个与任何IP匹配的通配符条目?我尝试使用
samenet
,但没有效果。您可以使用
all
。。。试试看。如果可以连接,请使用
选择inet\u client\u addr()
。您还可以尝试添加一些
local
条目,以防
pg
使用本地unix套接字。谢谢,但不幸的是
all
没有帮助。我记录了我的连接URL,它是
postgres://localhost:5432/mydatabase
,所以我尝试添加
host all localhost:5432 trust
。。。但那没用。因此,我很确定我是通过localhost进入的,但无论出于何种原因,我的“trust localhost”行似乎没有被使用(添加端口也没有帮助)。关于
psql-U me-W
如果不指定主机地址(
-h
选项)-
psql
(以及我想的任何其他客户端)使用
本地
连接类型。因此,首先,尝试使用
psql-U me-h localhost
连接到DB。