如何从外部网络查看postgresql数据库中的所有表?
how to view all tables in postgresql database from outside network?
我在其中一个本地网络中托管了 PostgreSQL 数据库。
在 fourm 和其他博客的帮助下。我可以管理从其他计算机连接数据库。我修改了PostgreSQL的配置文件,让所有IP都可以访问数据库。
我可以连接到数据库。但我无法查看其中的任何表格。我正在使用 pgAdmin 工具进行连接。 Pgadmin 工具正在连接,我看到了所有活动,但我可以查看任何表格。
有几件事,你有没有为特定数据库创建表的特定模式?
此外,当您说您已连接到数据库时,我感觉您连接的是默认数据库 "Postgres" 而不是您的用户数据库。
要在 pgamdin 中切换数据库,请单击左侧的数据库,然后双击或连接到用户数据库(您的数据库),您应该能够看到其中的表。
尝试一下,如果它不起作用,您可以随时使用终端使用以下命令连接到您的数据库:
psql -h hostname -d databasename -U username
这会提示输入密码,输入密码并使用以下命令列出数据库的
\l
>>> 列出数据库。
如果您连接到 postgres 并且想要切换用户:
\c databasename
连接到包含您的表的数据库后,使用以下命令列出它们:
\dt
希望对您有所帮助!
详情请见下方。
root@OpenProject:/home/XXXXXXXX# psql -h 192.168.1.146 -d openproject -U vivek
Password for user vivek:
psql (12.1 (Ubuntu 12.1-1.pgdg18.04+1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.
openproject=> \l openproject=> \c SSL connection (protocol: TLSv1.3,
cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off) You are
now connected to database "openproject" as user "craftsilicon".
openproject=> \dt Did not find any relations. openproject=> \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-------------+----------+----------+---------+-------+---------------------------
openproject | postgres | UTF8 | en_IN | en_IN | =Tc/postgres +
| | | | | postgres=CTc/postgres +
| | | | | craftsilicon=CTc/postgres
postgres | postgres | UTF8 | en_IN | en_IN |
template0 | postgres | UTF8 | en_IN | en_IN | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_IN | en_IN | =c/postgres +
| | | | | postgres=CTc/postgres
(4 rows)
openproject=> \c SSL connection (protocol: TLSv1.3, cipher:
TLS_AES_256_GCM_SHA384, bits: 256, compression: off) You are now
connected to database "openproject" as user "craftsilicon".
openproject=> \dt Did not find any relations.
我不知道,openproject 的表存储在哪里,我
想要访问表格。
已解决:- 通过以下方法。
我发现系统10和12安装了两个postgresql。
我连接到 12 的数据库。
但是openproject表要10个。
所以我卸载了 postgresql 12。
我在配置文件中配置了postgresql允许所有ip。
重启postgresql后。我可以查看所有表格。
非常感谢大家的帮助
我在其中一个本地网络中托管了 PostgreSQL 数据库。 在 fourm 和其他博客的帮助下。我可以管理从其他计算机连接数据库。我修改了PostgreSQL的配置文件,让所有IP都可以访问数据库。
我可以连接到数据库。但我无法查看其中的任何表格。我正在使用 pgAdmin 工具进行连接。 Pgadmin 工具正在连接,我看到了所有活动,但我可以查看任何表格。
有几件事,你有没有为特定数据库创建表的特定模式?
此外,当您说您已连接到数据库时,我感觉您连接的是默认数据库 "Postgres" 而不是您的用户数据库。
要在 pgamdin 中切换数据库,请单击左侧的数据库,然后双击或连接到用户数据库(您的数据库),您应该能够看到其中的表。
尝试一下,如果它不起作用,您可以随时使用终端使用以下命令连接到您的数据库:
psql -h hostname -d databasename -U username
这会提示输入密码,输入密码并使用以下命令列出数据库的
\l
>>> 列出数据库。
如果您连接到 postgres 并且想要切换用户:
\c databasename
连接到包含您的表的数据库后,使用以下命令列出它们:
\dt
希望对您有所帮助!
详情请见下方。
root@OpenProject:/home/XXXXXXXX# psql -h 192.168.1.146 -d openproject -U vivek
Password for user vivek:
psql (12.1 (Ubuntu 12.1-1.pgdg18.04+1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.
openproject=> \l openproject=> \c SSL connection (protocol: TLSv1.3,
cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off) You are
now connected to database "openproject" as user "craftsilicon".
openproject=> \dt Did not find any relations. openproject=> \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-------------+----------+----------+---------+-------+---------------------------
openproject | postgres | UTF8 | en_IN | en_IN | =Tc/postgres +
| | | | | postgres=CTc/postgres +
| | | | | craftsilicon=CTc/postgres
postgres | postgres | UTF8 | en_IN | en_IN |
template0 | postgres | UTF8 | en_IN | en_IN | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_IN | en_IN | =c/postgres +
| | | | | postgres=CTc/postgres
(4 rows)
openproject=> \c SSL connection (protocol: TLSv1.3, cipher:
TLS_AES_256_GCM_SHA384, bits: 256, compression: off) You are now
connected to database "openproject" as user "craftsilicon".
openproject=> \dt Did not find any relations.
我不知道,openproject 的表存储在哪里,我 想要访问表格。
已解决:- 通过以下方法。
我发现系统10和12安装了两个postgresql。 我连接到 12 的数据库。 但是openproject表要10个。 所以我卸载了 postgresql 12。 我在配置文件中配置了postgresql允许所有ip。 重启postgresql后。我可以查看所有表格。 非常感谢大家的帮助