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

2022-09-1109:39:53数据库教程Comments923 views字数 607阅读模式

1、概述

上一章节我们已经讲述了基于CentOS7.9的操作系统环境安装PostgreSQL的过程,本章将介绍Postgres数据库的常用命令和基本操作。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/27649.html

2、Postgre数据库的启停

2.1、切换到postgres用户

[root@localhost ~]# su - postgres文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/27649.html

2.2、查看PG数据库进程

[postgres@localhost ~]$ ps -aux|grep postgres文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/27649.html

PostgreSQL深入浅出 | 数据库的启动与停止文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/27649.html

2.3、启动数据库

[postgres@localhost ~]$ pg_ctl -D /usr/local/pgsql/pgdata -l /tmp/logfile start
/usr/local/pgsql/pgdata:数据库的数据目录
/tmp/logfile:指定日志文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/27649.html

PostgreSQL深入浅出 | 数据库的启动与停止文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/27649.html

启动成功后检查进程
[postgres@localhost ~]$ ps -aux|grep postgres文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/27649.html

PostgreSQL深入浅出 | 数据库的启动与停止文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/27649.html

2.4、停止数据库

[postgres@localhost ~]$ pg_ctl stop -D /usr/local/pgsql/pgdata -m fast文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/27649.html

PostgreSQL深入浅出 | 数据库的启动与停止文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/27649.html

补充:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/27649.html

这里停止数据库使用的-m参数有三个常用选项:
smart: 需要等到所有连接断开后才关闭数据库。
fast: 可以理解为Oracle数据库的immdiate模式。
immediate:可以理解为Oracle数据库的abort模式。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/27649.html

3、查看PostgreSQL数据库

[postgres@localhost ~]$ pg_ctl status文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/27649.html

PostgreSQL深入浅出 | 数据库的启动与停止文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/27649.html

  • 本站内容整理自互联网,仅提供信息存储空间服务,以方便学习之用。如对文章、图片、字体等版权有疑问,请在下方留言,管理员看到后,将第一时间进行处理。
  • 转载请务必保留本文链接:https://www.cainiaoxueyuan.com/sjk/27649.html

Comment

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定