LinuxCommandLibrary

postgres

TLDR

Start PostgreSQL server

$ postgres -D [/var/lib/postgresql/data]
copy
Start in foreground with logging
$ postgres -D [/var/lib/postgresql/data] -c log_statement=all
copy
Start on specific port
$ postgres -D [/var/lib/postgresql/data] -p [5433]
copy
Start single-user mode
$ postgres --single -D [/var/lib/postgresql/data] [database]
copy
Show version
$ postgres --version
copy

SYNOPSIS

postgres [-D datadir] [-p port] [-c name=value] [options]

DESCRIPTION

postgres is the PostgreSQL database server process. It manages database files, handles connections, and executes SQL queries.
The server is typically started through pg_ctl or system service managers rather than directly. Direct invocation is useful for debugging or non-standard configurations.
Configuration parameters can be set on command line or in postgresql.conf. Runtime parameters control memory, connections, logging, and behavior.
Single-user mode bypasses normal startup for maintenance. It's used for recovery operations when the database won't start normally.
The data directory contains all database files. It must be initialized with initdb before first use and is not portable between major versions.
Logging options help diagnose problems. Statement logging shows all SQL. Connection logging tracks client access.

PARAMETERS

-D DIR

Data directory.
-p PORT
Port number.
-c NAME=VALUE
Set runtime parameter.
-h HOST
Listen addresses.
-k DIR
Unix socket directory.
-B BUFFERS
Shared buffers.
-N N
Max connections.
--single
Single-user mode.
-F
Disable fsync.
--describe-config
Describe configuration.
--version
Show version.

CAVEATS

Running directly bypasses service management. Data directory must be secure. Configuration affects performance significantly. Major version upgrades need pg_upgrade.

HISTORY

PostgreSQL development began at UC Berkeley in 1986 as POSTGRES (Post-Ingres). The open-source PostgreSQL project started in 1996. It's now one of the most advanced open-source databases.

SEE ALSO

pg_ctl(1), initdb(1), psql(1), pg_dump(1)

Copied to clipboard