下午好。
我在连接到 Postgres 数据库时遇到问题。
我正在开发的应用程序必须在 .NET 4 上运行。我正在使用 Npgsql,因为我仅限于 .NET 4,所以我使用 Npgsql 版本 2.2.7(我相信 3+ 需要 .NET 4.5) )。
该应用程序将与 Postgres 运行在同一台计算机上。该数据库是由第三方安装和设置的,因此我无法更改 pg_hba.conf 文件。
我对连接字符串的第一次尝试如下所示:
Server=localhost;Database=xyz;Integrated Security=true;
但我收到了这个错误:
FATAL: 28000: no pg_hba.conf entry for host "::1", user "SYSTEM", database "xyz", SSL off
研究了该错误,并尝试了连接字符串的许多其他变体来修复此问题,包括:
Server=127.0.0.1;Database=xyz;Integrated Security=true;
Server=-h 127.0.0.1;Database=xyz;Integrated Security=true;
Server=127.0.0.1/32;Database=xyz;Integrated Security=true;
Server=::1;Database=xyz;Integrated Security=true;
Server=::1/128;Database=xyz;Integrated Security=true;
但没有任何作用。我要么得到
FATAL: 28000 ...
错误,或者一个简单的
Failed to establish a connection to ...
pg_hba.conf 文件如下所示:
host all postgres 127.0.0.1/32 trust
host all xyz 127.0.0.1/32 trust
host all xyz ::1/128 trust
host all postgres ::1/128 trust
这一切都在Windows 7机器上运行,并且在网络连接上关闭了IPv6。
这可能很简单,但我能做什么呢?我无法更改 pg_hba.conf 文件,那么如何调整连接字符串才能工作?