gpt4 book ai didi

postgresql - 远程连接到谷歌云 VM 实例中的 postgreSQL 服务器

转载 作者:行者123 更新时间:2023-11-29 13:47:14 27 4
gpt4 key购买 nike

我无法从笔记本电脑远程访问谷歌云中 Ubuntu16.04 VM 实例中的 PostgreSQL 服务器。我已将我的笔记本电脑 IP 添加到 Google Cloud 中的 pg_hba.conf 并尝试了“md5”和“Trust”方法:

#IPv4 本地连接:
托管所有所有 127.0.0.1/32 md5
托管所有 [mylocalIP]/32 md5

此外,我在 postgresql.conf 中同时尝试了 * 和 [mylocalIP]:

# - Connection Settings 
listen_addresses = '*' # what IP address(es) to listen on;

在谷歌云防火墙中我有以下设置

default-allow-http  http-server     IP ranges: 0.0.0.0/0    tcp:80  Allow   1000    default
default-allow-https https-server IP ranges: 0.0.0.0/0 tcp:443 Allow 1000 default
default-allow-psql Apply to all IP ranges: 0.0.0.0/0 tcp:5432Allow 1000 default
Laptop Apply to all IP ranges: [mylocalIP]/32 all Allow 1000 default

我还可以使用 SSH key 将 putty 连接到我的 Google Cloud VM 实例,这样我就可以进行一些远程连接。

我认为这是谷歌云防火墙问题,因为我可以在我的本地虚拟机(win 2012 服务器)中使用远程连接到我的 postgreSQL 服务器,使用以下设置没有问题。

提前致谢!

最佳答案

在您的 pg_hba.conf 文件中,尝试添加以下行

host    all             all           0.0.0.0/0         md5

您的防火墙规则似乎是正确的。您只需要规则 tcp:5432 用于 ip 范围 0.0.0.0/0

关于postgresql - 远程连接到谷歌云 VM 实例中的 postgreSQL 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46358001/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com