下午好。
我在连接到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文件,那我怎样调整我的连接字符串才能使其工作呢?