Skip to content
Runbook

Install PostgreSQL on Fedora / RHEL

Open source SQL relational database, robust and standards-compliant.

Databasesqlrdbmsrelationalaciddatabase

Installation

Server (Fedora repositories) · dnf
sudo dnf install -y postgresql-server postgresql-contrib

postgresql-contrib provides the standard extensions.

Initialize the cluster · dnf
sudo postgresql-setup --initdb

MANDATORY step: the data directory is not created automatically.

Verify the installation

Verify
psql --version

Service

Start
sudo systemctl start postgresql
Stop
sudo systemctl stop postgresql
Status
sudo systemctl status postgresql
Restart
sudo systemctl restart postgresql
On boot
sudo systemctl enable postgresql

Important files

TypePathDescription
data/var/lib/pgsql/dataCluster data directory.
config/var/lib/pgsql/data/postgresql.confServer configuration, located in the data directory.
config/var/lib/pgsql/data/pg_hba.confClient authentication rules, located in the data directory.

Default ports

5432

Command-line tools

  • psqlInteractive SQL client.
  • pg_dumpLogical backup of a database.
  • pg_restoreRestore from a custom-format backup.
  • createdbQuickly create a database.
  • pg_ctlLow-level server control.

Uninstall

Uninstall
sudo systemctl stop postgresql
sudo dnf remove -y postgresql-server postgresql-contrib

The /var/lib/pgsql/data directory remains; delete it manually to wipe everything.

Good to know

  • On Fedora/RHEL, the cluster IS NOT initialized automatically: run postgresql-setup --initdb before the first startup.
  • For a specific major version, the official PGDG repository offers postgresqlNN-server packages (e.g. postgresql17-server) — verify against the version.

Installing on Fedora / RHEL

The postgresql-server and postgresql-contrib packages install the server and the standard extensions. The psql client is provided by the postgresql package, usually pulled in as a dependency.

Mandatory step: initialize the cluster

Unlike Debian/Ubuntu, the data directory is not created at install time. You must initialize it explicitly:

sudo postgresql-setup --initdb

Only after this step can you enable and start the service. Forgetting this command is the most common cause of startup failure on Fedora.

Once the cluster is initialized, enable and start the service in a single command:

sudo systemctl enable --now postgresql

The --now flag starts the service immediately while also enabling it at system boot.

First connection

The installation creates a postgres PostgreSQL role matching the system user of the same name. To open a first session, assume that system identity and launch the psql client:

sudo -u postgres psql

You get the postgres=# prompt, from which you can create your roles and databases. Type \q to quit.

File locations

The cluster and its configuration live together under /var/lib/pgsql/data. The postgresql.conf and pg_hba.conf files are therefore located directly in the data directory, and not under /etc as on Debian.

For a specific major version (for example PostgreSQL 17), use the official PGDG repository and its versioned postgresqlNN-server packages — verify against your Fedora/RHEL version.