---
title: 启动、登录和关闭PostgreSQL
description: - 启动数据库
url: "https://www.hikunpeng.com/document/detail/zh/kunpengdbs/ecosystemEnable/autodeploytool/kunpengdbsolution_06_0013.html"
---

# 启动、登录和关闭PostgreSQL

- 启动数据库

1. 切换到postgres用户。
  1 su - postgres

2. 启动数据库。
  1 /usr/local/pgsql/bin/pg_ctl -D /data/pgsql/data/ -l logfile start

3. 查看数据库进程，确认是否启动（如下图所示，则启动成功）。

- 登录数据库

1. 切换到postgres用户。
  1 su - postgres

2. 登录数据库。
  1 /usr/local/pgsql/bin/psql -U postgres


- 关闭数据库

  1. 切换到postgres用户。
    1 su - postgres

  2. 关闭数据库。
    1 /usr/local/pgsql/bin/pg_ctl -D /data/pgsql/data/ -l logfile stop
