在PostgreSQL中启用ident和md5身份验证

前端之家收集整理的这篇文章主要介绍了在PostgreSQL中启用ident和md5身份验证前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在Fedora 12上,我为自己设置了一个测试数据库,pg_hba.conf默认包含以下内容
# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

# "local" is for Unix domain socket connections only
local   all         all                               ident
# IPv4 local connections:
host    all         all         127.0.0.1/32          ident
# IPv6 local connections:
host    all         all         ::1/128               ident

我想启用md5登录,以便名为’foo’的Postgresql用户可以访问名为’foo’的数据库.但是,当我添加此行并重新启动postgres时:

local   foo         foo                               md5

使用我的常规用户帐户运行psql -U’foo’仍然会产生以下消息:

psql: FATAL:  Ident authentication Failed for user "foo"

在我通过md5登录到’foo’之前,我必须删除第一个本地行(有ident).

如何在保持身份验证的同时为’foo’启用md5身份验证?

https://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html表示条目的顺序为maters,具体为:

Since the pg_hba.conf records are
examined sequentially for each
connection attempt,the order of the
records is significant. Typically,
earlier records will have tight
connection match parameters and weaker
authentication methods,while later
records will have looser match
parameters and stronger authentication
methods. For example,one might wish
to use trust authentication for local
TCP/IP connections but require a
password for remote TCP/IP
connections. In this case a record
specifying trust authentication for
connections from 127.0.0.1 would
appear before a record specifying
password authentication for a wider
range of allowed client IP addresses.

(因此请尝试撤消订单 – 将您添加的行放在顶部)

原文链接:https://www.f2er.com/postgresql/192478.html

猜你在找的Postgre SQL相关文章