gpt4 book ai didi

postgresql - 无法按名称连接到本地计算机

转载 作者:行者123 更新时间:2023-11-29 12:57:42 26 4
gpt4 key购买 nike

我的本​​地 Windows 7 x64 机器上运行着 Postgres 9.5.3

当我连接到“本地主机”时,我的代码工作正常。如果我按名称连接到我的机器,我会收到此错误:

Opening connection to 'W7_Adam_Benson' on port 5432 as user 'postgres'
ERROR: Devart.Data.PostgreSql.PgSqlException (0x80004005): no pg_hba.conf entry for host "fe80::6d80:62eb:5bab:f7f6%10", user "postgres", database "postgres", SSL off

很明显它正在尝试连接 IPV6 而不是 IPV4,但那又怎样?

我的 pg_hba.conf 看起来像这样:

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# IPv4 local connections:
host all all 0.0.0.0/0 md5
host all all 127.0.0.1/32 md5

# IPv6 local connections:
host all all ::1/128 md5
host all all * md5

# Allow replication connections from localhost, by a user with the
# replication privilege.
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5
host all all * trust

感谢收到的任何帮助

最佳答案

如果您需要特定地址才能工作,请将此行添加到您的文件中:

host  all  all  fe80::6d80:62eb:5bab:f7f6/10  md5

但是,对于 LAN 访问,将此行添加到 pg_hba.conf 文件中的 IPv6 本地连接:

host  all  all  fe80::/10  md5

IPv6 中以 fe80:: 开头的地址是链路本地地址,仅用于本地网络的一个网段或点对点连接类型中的通信。它们无法通过互联网/不同的子网进行路由。

关于postgresql - 无法按名称连接到本地计算机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38898217/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com