1、概述
上一章节我们已经讲述了基于CentOS7.9的操作系统环境安装PostgreSQL的过程,本章将介绍Postgres数据库的常用命令和基本操作。2、Postgre数据库的启停
2.1、切换到postgres用户
[root@localhost ~]# su - postgres2.2、查看PG数据库进程
[postgres@localhost ~]$ ps -aux|grep postgres
2.3、启动数据库
[postgres@localhost ~]$ pg_ctl -D /usr/local/pgsql/pgdata -l /tmp/logfile start/usr/local/pgsql/pgdata:数据库的数据目录
/tmp/logfile:指定日志

启动成功后检查进程
[postgres@localhost ~]$ ps -aux|grep postgres

2.4、停止数据库
[postgres@localhost ~]$ pg_ctl stop -D /usr/local/pgsql/pgdata -m fast
补充:
这里停止数据库使用的-m参数有三个常用选项:
smart: 需要等到所有连接断开后才关闭数据库。
fast: 可以理解为Oracle数据库的immdiate模式。
immediate:可以理解为Oracle数据库的abort模式。
3、查看PostgreSQL数据库
[postgres@localhost ~]$ pg_ctl status
最后修改时间:2022-08-25 13:46:50
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




