In this tutorial we’ll learn how to install PostgreSQL on CentOS 7. We will also install and configure its prerequisites. PostgreSQL is a free, open-source object-relational database management system (object-RDBMS), similar to MySQL, and is standards-compliant and extensible. It is commonly used as a back-end for web and mobile applications.
I recommend to use a minimal CentOS server setup as a basis for the tutorial, that can be a virtual or a root server image with an CentOS 7 minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.
Install PostgreSQL on CentOS 7
Step 1. First, ensure your system is fully up-to-date by running the following:
yum -y update
Step 2. Installing PostgreSQL.
Run the following command to install PostgreSQL repository:
yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
Now, Install postgresql with the following command:
yum install postgresql96-server postgresql96
Start PostgreSQL service using the following command as per your operating systems. Also, enable PostgreSQL service to auto start on system boot:
systemctl start postgresql-9.6 systemctl enable postgresql-9.6
Step 3. Verify PostgreSQL Installation.
Let’s log in to postfix to verify that installation completed successfully:
su - postgres
Use psql command to access PostgreSQL prompt with admin privileges:
$ psql psql (9.6.0) Type "help" for help. postgres=#
You may create password for user postgres for security purpose:
postgres=# \password postgres
Congratulation’s! You have successfully configured PostgreSQL on your CentOS 7 server.