无法使用pgadmin连接到Postgres

3

我正在尝试连接我的PostgreSQL数据库,它安装在AWS EC2实例上。

我已经在本地的Ubuntu机器上安装了pgadmin3,并尝试连接我的PostgreSQL,但是出现了错误:

 reports could not connect to server: Connection refused Is the server running on host "myip" and accepting TCP/IP connections on port 5432? 

在AWS上,我已经开放了5432端口。
我编辑了我的postgresql.conf文件,并添加了以下内容:
 listen_addresses = '*'

我在pg_hba.conf文件中添加了以下内容:

host    all         all         192.168.1.0/24        md5

但现在我遇到了这个错误:
 FATAL: no pg_hba.conf entry for host "myip", user "postgres", database "postgres", SSL on FATAL: no pg_hba.conf entry for host "myip", user "postgres", database "postgres", SSL off getting this error
2个回答

3
我通过在postgresql.conf文件中添加以下行来解决了这个问题:
listen_addresses = '*'

postgresql.conf的文件位置是:

/etc/postgresql/9.5/main/postgresql.conf

我在pg_hba.conf文件中添加了以下行:

 # IPv4 local connections:
 host    all             all             0.0.0.0/0               md5
 host    all             all             127.0.0.1/32            md5

然后使用以下命令重新启动postgres服务:

sudo service postgresql restart

1
你需要编辑 postgresql.conf 文件并更改包含 'listen_addresses' 的行。
listen_addresses = '*'

然后你需要编辑pg_hba.conf文件。在这个文件中,你需要设置可以连接到该服务器的计算机以及可以使用哪种身份验证方法。通常你需要类似的行:
host    all         all         192.168.1.0/24        md5

我正在使用Ubuntu,那个文件在哪里? - user9833077
1
请查看此位置:/etc/postgresql/9.3/main。将9.3替换为您安装的版本。 - Aefits
这个文件 pg_hba.conf 是空的。 - user9833077
严重错误:没有针对主机“myip”,用户“postgres”,数据库“postgres”的pg_hba.conf条目,SSL打开 严重错误:没有针对主机“myip”,用户“postgres”,数据库“postgres”的pg_hba.conf条目,SSL关闭 出现此错误 - user9833077
请看这个 Stack Overflow 的帖子:https://dev59.com/qGUq5IYBdhLWcg3wYvZ6 - Aefits

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接