PostgreSQL 11 Released. It is an open source object-relational, highly scalable, SQL-compliant database management system. PostgreSQL is developed at the University of California at Berkeley Computer Science Department. This article will help you to install PostgreSQL 11 on CentOS/RHEL 7/6 system.
This article has been tested on CentOS Linux release 7.5
Step 1 – Configure Yum Repository
Firstly you need to configure the PostgreSQL repository in your system. Use one of the below commands as per your operating system version.
## CentOS/RHEL - 7 rpm -Uvh https://yum.postgresql.org/11/redhat/rhel-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm ## CentOS/RHEL - 6 rpm -Uvh https://yum.postgresql.org/11/redhat/rhel-6-x86_64/pgdg-redhat-repo-latest.noarch.rpm
For more details visit PostgreSQL repositories link page where you can get repository package rpm for various operating systems.
Step 2 – Install PostgreSQL 11 on CentOS
After enabling PostgreSQL yum repository in your system use following command to install PostgreSQL 11 on your system with yum package manager.
yum install postgresql11-server
This will also install some additional required packages on your system. Enter y to confirm and complete the installation process.
Step 3 – Initialize PGDATA
After that, you need to initialize the PostgreSQL instance. In other words, this will create a data directory and other configuration files on your system. To initialize database use below command.
Above command will take some time to initialize PostgreSQL first time. PGDATA environment variable contains the path of data directory.
PostgreSQL 11 default data directory location is /var/lib/pgsql/11/data
Setp 4 – Start PostgreSQL Server
To start PostgreSQL service using the following command as per your operating systems. Also, enable PostgreSQL service to autostart on system boot.
CentOS/RHEL – 7
systemctl enable postgresql-11.service systemctl start postgresql-11.service
CentOS/RHEL – 6
service postgresql-11 start chkconfig postgresql-11 on
Step 5 – Verify PostgreSQL Installation
After completing the above all steps. Your PostgreSQL 11 server is ready to use. Log in to postfix instance to verify the connection.
su - postgres -c "psql" psql (11.0) Type "help" for help. postgres=#
You may create a password for user postgres for security purpose.
In conclusion, You have successfully installed the PostgreSQL database server on CentOS/RHEL 7/6 system.