无法连接到 ubuntu 上的 postgres

Can't connect to postgres on ubuntu

我在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)

如您所见,在 matt 用户名下看不到 Superuser 和数据库 strapi

                                   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 周,但无法正常工作。

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

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

正如上面提到的ex4,我需要联系我租用云计算机的公司,但我仍然无法连接到数据库。

我绕过它的方法是,您可以 ssh 进入您的数据库,然后作为 localhost 连接到您的数据库,因为您 ssh 进入您的云计算机。

在 DBeaver 中,您有一个 ssh 选项卡,您可以连接,然后返回到 postgres 选项卡并填写 localhostuserdatabase nameuser password 区域,只需单击 connect

遗憾的是,这需要数周时间才能完成:/