我尝试连接我的PostgreSQL实例已经有很多天了,现在决定寻求帮助。
我正在尝试从Windows机器连接到我的PostgreSQL数据库。
我正在使用pgAdmin 4和dBeaver,但都无法连接。下面是使用dBeaver连接时收到的错误截图:
我创建的连接如下:
我的用户是 (\du
):
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
umberto | Superuser, Create role, Create DB | {}
我的数据库(\l
):
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+---------+---------+-----------------------
postgres | postgres | UTF8 | C.UTF-8 | C.UTF-8 |
template0 | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
umberto | umberto | UTF8 | C.UTF-8 | C.UTF-8 |
wondermap | postgres | UTF8 | C.UTF-8 | C.UTF-8 |
我不确定在服务器上应该去哪里查找日志以解决这个问题。我唯一能找到的是文件夹/var/log/postgresql
,但我只看到了两个非gzipped文件,而且这些消息都是指向连接尝试之前的几天。
最后是我的pg_hba.conf
:
# Database administrative login by Unix domain socket
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all 0.0.0.0/0 md5
# IPv6 local connections:
host all all ::1/128 md5
host all all ::0/0 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
host all all ::/0 md5
可能会出现什么问题?
portqry -n [pg 主机名] -e 5432
并查看结果。 "Listening" = 能够访问服务器上的该端口并且某些东西(希望是 pg)正在侦听该端口; "Not listening" = 您能够访问该端口,但没有任何内容在侦听它(可能会导致超时); "Filtered" = 访问被阻止,几乎肯定是由于防火墙。 - 404