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

2023年 7月 11日 21.9k 0

1、概述

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

2、Postgre数据库的启停

2.1、切换到postgres用户

[root@localhost ~]# su - postgres

2.2、查看PG数据库进程

[postgres@localhost ~]$ ps -aux|grep postgres

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

2.3、启动数据库

[postgres@localhost ~]$ pg_ctl -D /usr/local/pgsql/pgdata -l /tmp/logfile start /usr/local/pgsql/pgdata:数据库的数据目录 /tmp/logfile:指定日志

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

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

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

2.4、停止数据库

[postgres@localhost ~]$ pg_ctl stop -D /usr/local/pgsql/pgdata -m fast

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

补充:

这里停止数据库使用的-m参数有三个常用选项: smart: 需要等到所有连接断开后才关闭数据库。 fast: 可以理解为Oracle数据库的immdiate模式。 immediate:可以理解为Oracle数据库的abort模式。

3、查看PostgreSQL数据库

[postgres@localhost ~]$ pg_ctl status

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

相关文章

Oracle如何使用授予和撤销权限的语法和示例
Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
社区版oceanbase安装
Oracle 导出CSV工具-sqluldr2
ETL数据集成丨快速将MySQL数据迁移至Doris数据库

发布评论