首页 > 技术 > 数据库

PostgreSQL深入浅出 | 数据库的启动与停止

数据库 2022-12-07 20:14:39

1、概述

上一章节我们已经讲述了基于CentOS7.9的操作系统环境安装PostgreSQL的过程,本章将介绍Postgres数据库的常用命令和基本操作。


2、Postgre数据库的启停

2.1、切换到postgres用户

[root@localhost ~]# su - postgres


2.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


TAg

加载中~

本网站LOGO受版权及商标保护,版权登记号:国作登字-2022-F-10126915,未经湖南木星科技官方许可,严禁使用。
Copyright © 2012-2022 湖南木星科技有限公司(木星网)版权所有
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源,商业媒体及纸媒请先联系:aishangyiwan@126.com

工信部备案号:湘ICP备19012813号-5