pg_hba.conf - psql 本地无密码登录

pg_hba.conf - psql 本地无密码登录

pg_hba.conf我在PostgreSQL-12.6 安装中有这些设置

# "local" is for Unix domain socket connections only
local   all             all                                     md5
local   all             postgres                                trust   # ident
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust   # md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     trust
host    replication     all             127.0.0.1/32            trust
host    replication     all             ::1/128                 trust

local all postgres trust希望允许我本地登录psql 没有以 unix 用户身份查询密码postgres

然而:

postgres@my-vm:/opt/db/postgres/bin> psql
Password for user postgres:

postgres当前用户还没有 psql 密码

答案1

local  all  all       md5  
local  all  postgres  trust   # ident  

请记住,pg_hba 中的条目会被处理按照他们给出的顺序

“本地所有 postgres 信任”...应该允许我登录...无需...密码

而且它,如果出现迫使每一个要使用的本地连接md5验证!

相关内容