Skip to main content

PostgreSQL Installation Guide

This guide provides all the key information and getting-started instructions after a successful PostgreSQL installation via DeploySage-CLI.

Installation Summary

Below is the core configuration information for your PostgreSQL installation. The specific version number (e.g., 16) will vary based on your selection.

ItemValue
Installed VersionPostgreSQL 13/14/15/16
Service Namepostgresql-16
Data Directory/var/lib/pgsql/16/data
Main Configuration File.../data/postgresql.conf
Access Control File.../data/pg_hba.conf

Usage Guide

Service Management

Connecting to the Database

Common psql Commands

Manage the PostgreSQL service for your selected version using standard systemctl commands. Replace postgresql-16 with the specific service name for your installed version.

After installation, a Linux user named postgres is created to manage the database. You must first switch to this user to access the database.

Alternatively, you can directly enter psql with this command:

Once inside the psql command line, you can use the following meta-commands:

# Start the service
sudo systemctl start postgresql-16

# Stop the service
sudo systemctl stop postgresql-16

# Restart the service
sudo systemctl restart postgresql-16

# Check the service status
sudo systemctl status postgresql-16
# 1. Switch to the postgres user
sudo su - postgres

# 2. Enter the psql command line
psql
sudo -u postgres psql
\l        -- List all databases
\c dbname -- Connect to a specific database
\dt -- Display tables in the current database
\du -- List all users (roles)
\q -- Quit psql

Important Notes