【发布时间】:2015-06-30 09:34:12
【问题描述】:
如果我说-h localhost,Postgres 不接受连接,但如果我说-h 127.0.0.1,它就可以工作
[root@5d9ca0effd7f opensips]# psql -U postgres -h localhost -W
Password for user postgres:
psql: FATAL: Ident authentication failed for user "postgres"
[root@5d9ca0effd7f opensips]# psql -U postgres -h 127.0.0.1 -W
Password for user postgres:
psql (8.4.20)
Type "help" for help.
postgres=#
我的/var/lib/pgsql/data/pg_hba.conf
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
local all all ident
# IPv4 local connections:
host all all 127.0.0.1/32 trust
host all all 127.0.0.1/32 ident
# IPv6 local connections:
host all all ::1/128 ident
如果我添加以下行,则 Postgres 服务 failed 开始:
host all all localhost ident
host all all localhost trust
那里出了什么问题?
更新
我的/etc/hosts 文件:
[root@5d9ca0effd7f opensips]# cat /etc/hosts
172.17.0.2 5d9ca0effd7f
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
【问题讨论】:
-
我的猜测:localhost 未定义为 127.0.0.1 的网络别名。我在您的配置文件中看到“本地”,但没有看到“本地主机”。
-
你也可以检查你的 /etc/host 的环回地址吗?
-
在
127.0.0.1 localhost中有/etc/hosts我也更新了我的问题 -
显然您必须提供您的 Postgres 版本。它像你的 psql 一样是 8.4 吗?顺便说一句,“Postgress”不是一个有效的名称。
标签: sql linux postgresql connection