无法通过Pgadmin 4连接到远程服务器上的PostgreSQL

问题描述 投票:0回答:2

我最近在Azure上安装了Ubuntu 14.04。一直在尝试连接到PostgreSQL但服务器拒绝连接。我检查并确认它在线。我还尝试将设置更改为信任pg_hba.conf,我还编辑了Postgresql.conf文件以收听所有地址。此外,我检查了Windows上的防火墙设置,并允许Pgadmin 4通过。尽管遵循了这个问题中的所有说明(Unable to connect PostgreSQL to remote database using pgAdmin),但我无法连接。我该怎么办?

postgresql ubuntu pgadmin-4
2个回答
0
投票

使您的postgresql服务器在启动时启动

sudo systemctl enable postgresql

启动postgresql服务器

sudo systemctl start postgresql

验证您的postgresql服务器是否正在运行:

sudo systemctl status postgresql

0
投票

我曾经在win 10上遇到pgAdmin4这样的问题。这是我连接到远程服务器的步骤

首先启用端口5432以通过ubuntu中的防火墙:

sudo ufw allow 5432/tcp

然后编辑postgresql.conf文件并添加

listen_addresses =“*”

文件可以在/etc/postgresql//main/postgresql.conf找到

继续编辑pg_hba.conf并添加

host   all   all  0.0.0.0/0   md5

现在使用/etc/init.d/postgresql stop停止服务器并重新启动/etc/init.d/postgresql start

你应该能够立即连接。但是,您可以允许pgAdmin4通过Windows防火墙

control panel > System and Security > Allow an app through windows firewall

您还可以为您安装的任何防病毒软件允许使用相同的应用程序

注意:如果仍然无法连接,可以重置postgres用户的密码而不是linux默认用户

sudo -u postgres psql postgres
# \password postgres
Enter new password

然后使用此新密码连接您的pgAdmin4

  • postgres作为维护数据库
  • postgres作为用户名
  • 然后是新密码

希望你能够连接

© www.soinside.com 2019 - 2024. All rights reserved.