YUM Installation

From PostgreSQL wiki
(Redirected from RPM Installation)
Jump to: navigation, search

PostgreSQL can be installed using RPMs (binary) or SRPMs (source) managed by YUM or DNF . This is available for the following Linux distributions (both 32- and 64-bit platforms; for the current release and prior release or two):

  • Fedora
  • Red Hat Enterprise Linux
  • CentOS
  • Scientific Linux (EOLed)
  • Oracle Enterprise Linux

See links from the main repository, http://yum.postgresql.org:


Configure your YUM repository

Locate and edit your distributions .repo file, located:

  • On Fedora: /etc/yum.repos.d/fedora.repo and /etc/yum.repos.d/fedora-updates.repo, [fedora] sections
  • On CentOS: /etc/yum.repos.d/CentOS-Base.repo, [base] and [updates] sections
  • On Red Hat: /etc/yum/pluginconf.d/rhnplugin.conf [main] section

To the section(s) identified above, you need to append a line (otherwise dependencies might resolve to the postgresql supplied by the base repository):


Install PGDG Repo RPM and PostgreSQL

Follow the instructions in https://www.postgresql.org/download/linux/redhat/ .

Other packages can be installed according to your needs.

Post-installation commands

After installing the packages, a database needs to be initialized and configured.

In the commands below, the value of <name> will vary depending on the version of PostgreSQL used.

For PostgreSQL versions from 10 and above, the <name> includes the major version of PostgreSQL, e.g., 12

For PostgreSQL versions from 9.4 to 9.6, the <name> includes the major.minor version of PostgreSQL, e.g., 9.6

Data Directory

The PostgreSQL data directory contains all of the data files for the database. The variable PGDATA is used to reference this directory.

The default data directory is:


For example:



The first command (only needed once) is to initialize the database in PGDATA.

For RHEL/CentOS 7, 8, and Fedora 30 and above:

If the previous command did not work, try directly calling the setup binary, located in a similar naming scheme:

/usr/pgsql-y.x/bin/postgresqlyx-setup initdb

For versions 10 and above:

/usr/pgsql-12/bin/postgresql-12-setup initdb (Notice the extra dash before major version)

E.g. for version 9.6:

/usr/pgsql-9.6/bin/postgresql96-setup initdb

For Red Hat 6:

service <name> initdb

E.g. for version 9.6:

service postgresql-9.6 initdb


If you want PostgreSQL to start automatically when the OS starts, do the following:

In RHEL 7+, and Fedora 30+ try:

 systemctl enable postgresql-12.service

In RHEL 6 and PostgreSQL 12:

chkconfig postgresql-12 on

Control service

To control the database service, use:

With RHEL/CentOS 7, 8 , and Fedora 30:

 systemctl enable postgresql-12.service
 systemctl start postgresql-12.service

for RHEL/CentOS 6:

service <name> <command>

where <command> can be:

  • start : start the database
  • stop : stop the database
  • restart : stop/start the database; used to read changes to core configuration files
  • reload : reload pg_hba.conf file while keeping database running

E.g. to start version 12:

service postgresql-12 start


To remove everything:

yum erase postgresql12*
dnf remove postgresql12* for RHEL 8 and Fedora 30+ 

Or remove individual packages as desired.


  • Email: pgsql-pkg-yum@listspostgresql.org (requires subscription)

After installation

First steps in PostgreSQL