How to Installation PostgreSQL 12 on Redhat and Centos 6,7 Linux


PostgreSQL 12 An open-source object is a relational, highly scalable, SQL-compliant database management system. PostgreSQL was developed at the University of California at the Berkeley Computer Science Department. This article will help you install PostgreSQL 12 on a CentOS / RHEL 7/6 system.

CentOS’s default repositories contain postgresql packages, so we can install them seamlessly using the yum package system. Since we want to install the latest version, we are installing the RPM repository containing PostgreSQL 12.

yum -y install  

yum -y install  

yum -y install yum-utils  

yum-config-manager –enable pgdg12  

yum install postgresql12-server postgresql12  

  1. No match for argument: postgresql12-server  
  2. No match for argument: postgresql12 

yum -qy module disable postgresql

yum install postgresql12-server postgresql12
Last metadata expiration check: 0:05:25 ago on Mon 07 Nov 2019 12:06:20 PM CEST.

postgresql12-server x86_64 12.0-1PGDG.rhel8 pgdg12 5.1 M
Installing dependencies:
python2-setuptools noarch 39.0.1-10.el8+5120+95a111a8 ol8_beta 643 k
python2-libs x86_64 2.7.15-15.0.1.el8+5120+95a111a8 ol8_beta 6.0 M
python2 x86_64 2.7.15-15.0.1.el8+5120+95a111a8 ol8_beta 106 k
postgresql12 x86_64 12.0-1PGDG.rhel8 pgdg12 1.5 M
postgresql12-libs x86_64 12.0-1PGDG.rhel8 pgdg12 390 k
Enabling module streams:
python27 2.7

After that, you must start the PostgreSQL instance. In other words, this will create a data directory and other configuration files on your system. Use the following command to start the database.

/usr/pgsql-12/bin/postgresql-12-setup initdb

Centos/Redhat 7

systemctl enable postgresql-12.service

systemctl start postgresql-12.service

Centos/Redhat 6

service postgresql-12 start

chkconfig postgresql-12 on

By default, a connection to the postgres database with the postgres user via localhost is provided via port 5432. The syntax for connecting to a database with psql is as follows:

psql –host=localhost –dbname=postgres –username=postgres –port=5432


Marek Michalski
Two small difference in excellent guide. yum -y install yum-config-manager enable pgdg12 Thanks a lot
Reply · 3 years ago