我已经在Windows 10上安装了使用EDB安装程序的PostgreSQL 13,它似乎工作得很好。我可以很容易地在包含的SQL Shell应用程序中连接psql。然而,我不能从powershell连接:
~> psql -U postgres -h localhost
psql: error: could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
psql命令行开关的任何排列都会产生相同的结果。我检查了pg_hba。conf,它看起来是正常的——所有本地连接都被允许。在互联网上搜索上述错误代码的所有结果都假定服务器没有运行,但它运行得很好(参见上面的SQL Shell)。在这个shell中,所有的postgres表都是可见的。我需要做什么连接psql到服务器的localhost从powershell?
默认安装pg_hba。conf:
# "local" is for Unix domain socket connections only
local all all scram-sha-256
# IPv4 local connections:
host all all 127.0.0.1/32 scram-sha-256
# IPv6 local connections:
host all all ::1/128 scram-sha-256
上面的IPv4行应该涵盖了powershell?是吗?在postgresql。conf文件中允许TCP连接:
listen_addresses = '*' # what IP address(es) to listen on;
长时间的linux PostgreSQL用户第一次在Windows上的powershell…
###今天早上我发现了这个问题- EDB安装程序设置了postgres服务在端口5433上运行。在5432上运行了几十年之后,我甚至没有注意到这个数字在postgresql.conf
. It was late...
5432上肯定有别的东西在运行。稍后会查看。