• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Install PostgreSQL 10 on CentOS/RHEL 7/6 and Fedora 28-26

Written by Rahul, Updated on June 20, 2018
PostgreSQL pg_data, postgres, PostgreSQL, psql

PostgreSQL 10 Released. PostgreSQL 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 10 on CentOS, RHEL and Fedora Systems.

Step 1 – Add Postgres Yum Repository

The first step is to install PostgreSQL repository in your system, Use one of below commands as per your system architecture and operating system.

## CentOS/RHEL - 7
rpm -Uvh https://yum.postgresql.org/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm

## CentOS/RHEL - 6
rpm -Uvh https://yum.postgresql.org/10/redhat/rhel-6-x86_64/pgdg-redhat10-10-2.noarch.rpm

## Fedora - 28
rpm -Uvh https://yum.postgresql.org/10/fedora/fedora-28-x86_64/pgdg-fedora10-10-4.noarch.rpm

## Fedora - 27
rpm -Uvh https://yum.postgresql.org/10/fedora/fedora-27-x86_64/pgdg-fedora10-10-4.noarch.rpm

## Fedora - 26
rpm -Uvh https://yum.postgresql.org/10/fedora/fedora-26-x86_64/pgdg-fedora10-10-4.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 10 Server

After enabling PostgreSQL yum repository in your system use following command to install PostgreSQL 10 on your system with yum package manager.

yum install postgresql10-server postgresql10

Step 3 – Initialize PGDATA

After installing PostgreSQL server, It’s required to initialize it before using the first time. To initialize database use below command.

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

Above command will take some time to initialize PostgreSQL first time. PGDATA environment variable contains the path of data directory.

PostgreSQL data directory Path: /var/lib/pgsql/10/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.

For CentOS/RHEL 7 and Fedora

systemctl start postgresql-10.service
systemctl enable postgresql-10.service

For CentOS/RHEL 6

service postgresql-10 start
chkconfig postgresql-10 on
Step 5 – Verify PostgreSQL Installation

After completing above steps, you have installed PostgreSQL 10 on your server, Let’s log in to postfix to verify that installation completed successfully.

su - postgres -c "psql"

psql (10.0)
Type "help" for help.
postgres=#

You may create a password for user postgres for security purpose.

postgres=# \password postgres

Congratulation’s! You have successfully installed PostgreSQL Server. Read below article to install phpPgAdmin.

How to Install phpPgAdmin on CentOS using Yum

Thanks for using this tutorial for installing PostgreSQL 10 on CentOS/RHEL 7/6 and Fedora 28/27/26 systems.

Share it!
Share on Facebook
Share on Twitter
Share on Google+
Share on Reddit
Share on Tumblr
Rahul
Rahul
Connect on Facebook Connect on Twitter Connect on Google+

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

Related Posts

  • How to Install PostgreSQL 11 on Debian 9 (Stretch)

    November 12, 2018
  • How to Install pgAdmin4 on Debian 9 (Stretch)

    November 12, 2018
  • How to Install and Configure pgAdmin4 on Ubuntu 18.04 & 16.04

    November 11, 2018
  • How to Install PostgreSQL 11 on Fedora 28/27/26

    October 30, 2018
  • How to Install PostgreSQL 11 on CentOS/RHEL 7/6

    October 29, 2018

14 Comments

  1. Bill K. Reply to Bill
    February 14, 2019 at 3:18 pm

    Great Article,! one slight update, yum repository for RHEL7 should be:
    ## CentOS/RHEL – 7
    rpm -Uvh https://yum.postgresql.org/10/redhat/rhel-7-x86_64/pgdg-redhat10-10-2.noarch.rpm

  2. George Reply to George
    October 26, 2018 at 6:34 pm

    Hi Rahul,

    Great!
    I can install postgresql in RHEL 7.5!!

    A hard Question: I want to restart my postgresql with “service postgresql restart” command, Should I have root profile? Or with my postgres account?

    Greetings!

  3. Jay Reply to Jay
    November 2, 2017 at 2:02 pm

    Thanks buddy… Just installed Postgresql 10 on CentOS system

  4. Nikhil Kulshrestha Reply to Nikhil
    August 10, 2017 at 7:26 pm

    service postgresql-9.6 initdb

    this command is showing failed

    • Rahul Rahul K. Reply to Rahul
      October 11, 2017 at 10:35 am

      Hi Nikhil, Please use below command ti initialize PostgreSQL database.

      For PostgreSQL 9.6:
      # /usr/pgsql-9.6/bin/postgresql96-setup initdb

      For PostgreSQL 10:
      # /usr/pgsql-10/bin/postgresql-10-setup initdb

  5. Dave Reply to Dave
    May 8, 2017 at 10:13 pm

    Nice site. Laid out very well.

    This worked for me in Fedora 25 for PostgreSQL 9.6:

    Initializing PGDATA

    # /usr/pgsql-9.6/bin/postgresql96-setup initdb

  6. Ashish Sharma Reply to Ashish
    March 25, 2017 at 9:18 pm

    Last command should be

    postgres=# password postgres

    • Rahul Rahul K. Reply to Rahul
      March 26, 2017 at 3:13 am

      Thanks Ashish,

      Tutorials has been updated.

  7. SG Reply to SG
    August 28, 2016 at 11:31 am

    your final command

    postgres=# password postgres

    How does that work?

    • Ashish Sharma Reply to Ashish
      March 25, 2017 at 9:19 pm

      postgres=# password postgres

  8. Ajayakumar BS Reply to Ajayakumar
    March 4, 2016 at 12:44 am

    initdb should be executed as postgres user.
    # su – postgres
    $/usr/pgsql-9.5/bin/initdb -D /var/lib/pgsql/9.5/data

    or

    # service postgresql-9.5 initdb

    • saïd Reply to saïd
      April 9, 2017 at 1:42 am

      I totally agrre. It is too dangerous to run as a root user !!!

      • Rahul Rahul K. Reply to Rahul
        April 10, 2017 at 9:27 am

        Hi said/Ajayakumar,

        Thanks for your views. I have updated tutorial as per suggestion of Ajayakumar BS.

  9. ALZ Reply to ALZ
    February 15, 2016 at 9:02 am

    I was not able to initdb on my CentOS 6.7 with next command:
    > Initializing PGDATA
    # /usr/pgsql-9.5/bin/postgresql95-setup initdb

    instead for me worked following:
    # service postgresql-9.5 initdb

Leave a Reply

Cancel reply

Popular Posts

  • How To Install Zabbix Agent on Debian 9/8
  • How to Install and Configure Squid Proxy on Debian 9
  • How To Install Wine 3 on Debian 9 (Stretch)
  • How to Remove “public/index.php” from URL in Laravel
  • How to Install Swift on Ubuntu 18.04 LTS
All rights reserved. © 2013-2018 TecAdmin.net. This site uses cookies. By using this website you agree our term and services