远程连接到PostgreSQL数据库

发布于 2025-01-19 08:01:43 字数 623 浏览 3 评论 0原文

我正在尝试从我的个人电脑在 pgAdmin 上远程连接到另一个网络上的 Windows 10 电脑上托管的数据库。

采取的步骤:

  • 将 postgresql.conf 文件中的 listen_addresses = 'localhost' 更改为 listen_addresses = '*'
  • host all all 0.0.0.0/0 行添加到 pg_hba.conf 文件中。
  • 重新启动 postgresql 服务。
  • 在防火墙中打开端口 5432

尝试通过我的 PC 上的 pgAdmin 连接到数据库,输入:

  • 主机名:托管计算机数据库的 IPv4 地址。
  • 端口:5432,数据库:postgres,用户:postgres,密码:password

除了每次都出现连接超时错误之外,我看不到任何错误,但我不知道为什么。我增加了连接超时时间,但仍然没有连接。 PostgreSQL 服务正在运行,我可以在托管 PC 上通过 pgAdmin 连接到数据库。

任何人都可以让我知道我是否要跳过某个步骤或需要添加到配置文件中的其他内容吗? 谢谢

I'm trying to connect remotely on pgAdmin to a database hosted on a Windows 10 PC on another network from my personal PC.

Steps taken:

  • Changed listen_addresses = 'localhost' to listen_addresses = '*' in postgresql.conf file.
  • Added line host all all 0.0.0.0/0 to pg_hba.conf file.
  • Restarted postgresql service.
  • Opened port in firewall for port 5432

Tried to connect to database via pgAdmin on my PC by entering:

  • Host name: IPv4 address of machine database is hosted on.
  • Port:5432, Database: postgres, user: postgres, password: password

I can't see any error except a connection timed out error every time, but I don't know why. I've increased the connection timeout duration but still no connection. PostgreSQL service is running and I can connect to the database via pgAdmin just fine on the hosting PC.

Can anyone let me know if I'm skipping a step or anything else I need to add to the config files?
Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文