Phone :  +370 (5) 204-1903
Email: sales@1gbits.com
  1. Dedicated server
  2. Blog
  3. How To Install PostgreSQL on Centos 7
How To Install PostgreSQL on Centos 7


Sep, 16

PostgreSQL, or Postgres, is a relational database management system that provides an implementation of the SQL querying language. It is a popular choice for many small and large projects and has the advantage of being standards-compliant and having many advanced features like reliable transactions and concurrency without read locks.

1. First, add PostgreSQL Yum repository to your system.

rpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-1.noarch.rpm

2. Install PostgreSQL server.

yum -y install postgresql94 postgresql94-server postgresql94-contrib

Once the postgresql94-server package is installed, you need to initialize a database:

/usr/pgsql-9.4/bin/postgresql94-setup initdb

3. Start PostgreSQL server.

systemctl start postgresql-9.4
systemctl enable postgresql-9.4

4. Configure Iptables or firewall. Adjust iptables to access postgresql from remote systems:

#nano /etc/sysconfig/iptables

firewall-cmd --permanent --add-port=5432/tcp
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --reload

5. Create test database and Create new user PostgreSQL. Once the installation is completed, you can start using the PostgreSQL 9.4 on your CentOS 7 by typing the commands:

su - postgres

Create test database (as postgres user).

createdb 1gbits

Login test database (as postgres user).

psql 1gbits

Delete database (as postgres user).

su - postgres

Congratulation’s! You have successfully installed PostgreSQL Server. Save Save

author img


Leave A Comment