Installing PostgreSQL 9.6 on CentOS 7 / Red Hat 7

Modified on Mon, 10 Oct, 2022 at 1:32 PM

The installation of PostgreSQL 9.6 needs to be done before installing Newired Portal


Below are listed all the commands to execute on the terminal of the server.


  1. Add the PostgreSQL 9.6 Repository
    yum install  https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-redhat96-9.6-3.noarch.rpm -y

  2. Install PostgreSQL 9.6
    yum install postgresql96 postgresql96-server postgresql96-contrib postgresql96-libs -y

  3. Init the PostgreSQL 9.6 service
    /usr/pgsql-9.6/bin/postgresql96-setup initdb

  4. Enable the PostgreSQL 9.6 service
    systemctl enable postgresql-9.6.service

  5. Start the PostgreSQL 9.6 service
    systemctl start postgresql-9.6.service

  6. Set the password for superuser postgres
    echo "ALTER USER postgres WITH PASSWORD '__NEW_PASSWORD__';" | su postgres -c "psql"

  7. Now, you need to allow the connection from localhost to the database over password.
    To do that, edit the file /var/lib/pgsql/9.6/data/pg_hba.conf and change

    host    all         all 127.0.0.1/32            indent

    to
    host    all         all 127.0.0.1/32            md5

  8. Restart the service
    systemctl restart postgresql-9.6.service

  9. Test the connection superuser (postgres) over password
    psql -h 127.0.0.1 -U postgres -W

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article