如何通过SSH隧道使用pgAdmin和Unix Domain Socket连接到远程PostgreSQL服务器

时间:2020-05-16 16:53:11

标签: postgresql pgadmin

我想使用pgAdmin从Windows计算机连接到远程PostgreSQL服务器。

我可以通过Unix套接字通过SSH隧道连接到服务器吗?? PostgreSQL服务器和隧道SSH服务器在同一台计算机上运行。

pgAdmin documentation中,“服务器对话框”的“主机名/地址”字段解释为:

在“主机名/地址”字段中指定服务器主机的IP地址或标准域名。 如果您提供的是Unix域套接字,则目录名称必须以“ /”开头

因此,我在该字段中指定了/var/run/postgresql以使用Unix域套接字,但是出现了以下错误消息:

Unable to connect to server:

server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.

这是服务器计算机的日志:

systemd[1]: Started Session 28 of user ***.
sshd[630]: pam_unix(sshd:session): session opened for user *** by (uid=0)
sshd[634]: error: connect_to /var/run/postgresql: unknown host (Name or service not known)
sshd[630]: pam_unix(sshd:session): session closed for user ***

当然,我可以使用服务器计算机上的unix域套接字连接到PostgreSQL服务器。 以下psql命令有效。

$ psql -h /var/run/postgresql -U *** -d *** 

0 个答案:

没有答案