首页 > 解决方案 > 无法连接到 ubuntu 上的 postgres

问题描述

我在dreamcompute(即云计算)上有一个ubuntu 20。

我创建了一个用户和一个数据库。这是数据库和用户的列表(由于某种原因,我在用户名下看不到数据库matt)。

我进入: nano /etc/postgresql/13/main/postgresql.conf& nano /etc/postgresql/13/main/pg_hba.conf并做了整个'*''0.0.0.0/0'

postgres=# \l
                              List of databases
   Name    |  Owner   | Encoding | Collate |  Ctype  |   Access privileges
-----------+----------+----------+---------+---------+-----------------------
 postgres  | postgres | UTF8     | C.UTF-8 | C.UTF-8 |
 strapi    | postgres | UTF8     | C.UTF-8 | C.UTF-8 | =Tc/postgres         +
           |          |          |         |         | postgres=CTc/postgres+
           |          |          |         |         | hossein=CTc/postgres
 template0 | postgres | UTF8     | C.UTF-8 | C.UTF-8 | =c/postgres          +
           |          |          |         |         | postgres=CTc/postgres
 template1 | postgres | UTF8     | C.UTF-8 | C.UTF-8 | =c/postgres          +
           |          |          |         |         | postgres=CTc/postgres
(4 rows)

如您所见,您看不到用户名下的Superuser数据库。strapimatt

                                   List of roles
 Role name |                         Attributes                         | Member of
-----------+------------------------------------------------------------+-----------
 matt      |                                                            | {}
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
 ubuntu    |                                                            | {}

我正在使用我梦想中的计算机ip address作为我的主机并使用我的数据库、用户和密码,但收到错误消息:connection attempt time out.

在此处输入图像描述

有人可以告诉我为什么会这样吗?我已经为此工作了 2 周,但我无法让它工作。

标签: databasepostgresqlubuntudbeaver

解决方案


错误信息是connection time out。这通常意味着该端口被防火墙阻止。检查您的云提供商防火墙设置,并iptables在您的 Linux 框中安装它。

如果权限有问题,则错误消息将是其他内容。


推荐阅读