Login
欢迎访问木星教程网_技术成就梦想 - 为知识分享服务

您现在的位置是: 首页 > 技术 > 数据库

数据库

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

2022-12-07 数据库 加入收藏
1、概述

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


原文地址: