栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

PostgreSQL-从宿主服务器进入pg docker容器维护数据库的方法

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

PostgreSQL-从宿主服务器进入pg docker容器维护数据库的方法

[root@localhost ubuntu]# docker ps|grep pg       1.查询需要进入的pg容器信息
[root@localhost ubuntu]# docker ps
ConTAINER ID   IMAGE            COMMAND                  CREATED       STATUS       PORTS      NAMES
158ee41a55c8   postgres:10.17   "docker-entrypoint.s…"   4 hours ago   Up 4 hours   5432/tcp   peaceful_cartwright
[root@localhost ubuntu]# docker ps|grep pos
158ee41a55c8   postgres:10.17   "docker-entrypoint.s…"   5 hours ago   Up 5 hours   5432/tcp   peaceful_cartwright
[root@localhost ubuntu]# docker exec -it peaceful_cartwright /bin/sh   2.进入指定的容器
# su - postgres     3.切换到数据库postgres用户
postgres@158ee41a55c8:~$ psql     4.切换到psql界面  
psql (10.17 (Debian 10.17-1.pgdg90+1))
Type "help" for help.

postgres=# select datname from pg_database;   5.查询数据库
  datname
-----------
 postgres
 template1
 template0
(3 rows)

postgres=# c postgres    6.进入指定的数据库
You are now connected to database "postgres" as user "postgres".
postgres=# select version();   7.执行相关的实际工作
                                                              version
------------------------------------------------------------------------------------------------------------------------------------
 PostgreSQL 10.17 (Debian 10.17-1.pgdg90+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516, 64-bit
(1 row)

postgres=# q    8.退出psql
postgres@158ee41a55c8:~$ exit   9.退出postgres
logout
# exit
[root@localhost ubuntu]#

 

 

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/307747.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号