Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Databases»PostgreSQL»How to Install PostgreSQL 9.6 on CentOS/RHEL 7

    How to Install PostgreSQL 9.6 on CentOS/RHEL 7

    By RahulOctober 24, 20222 Mins Read

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

    Advertisement
    Adding PostgreSQL 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 http://yum.postgresql.org/9.6/redhat/rhel-7-x86_64/pgdg-redhat96-9.6-3.noarch.rpm
    
    ### CentOS/RHEL 6 ###
    rpm -Uvh http://yum.postgresql.org/9.6/redhat/rhel-6-x86_64/pgdg-redhat96-9.6-3.noarch.rpm
    
    
    ### Fedora 26 ###
    rpm -Uvh http://yum.postgresql.org/9.6/fedora/fedora-26-x86_64/pgdg-fedora96-9.6-3.noarch.rpm
    
    ### Fedora 25 ###
    rpm -Uvh http://yum.postgresql.org/9.6/fedora/fedora-25-x86_64/pgdg-fedora96-9.6-3.noarch.rpm
    
    ### Fedora 24 ###
    rpm -Uvh http://yum.postgresql.org/9.6/fedora/fedora-25-x86_64/pgdg-fedora96-9.6-3.noarch.rpm
    

    For more details visit PostgreSQL repositories link page where you can get repository package rpm for various operating systems.

    Installing PostgreSQL Server

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

    yum install postgresql96-server postgresql96
    
    Initializing PGDATA

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

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

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

    PostgreSQL data directory Path: /var/lib/pgsql/9./data/

    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-9.6
    systemctl enable postgresql-9.6
    

    For CentOS/RHEL 6

    service  postgresql-9.6 start
    chkconfig postgresql-9.6 on
    
    Verify PostgreSQL Installation

    After completing above steps, you have installed PostgreSQL 9.6 on your server, 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.6)
    Type "help" for help.
    
    postgres=#
    

    You may create 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 9.6 on CentOS/RHEL 7/6 and Fedora 26/25/24 systems

    initdb pgsql phpPgAdmin postgres PostgreSQL psql
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Upgrade to Fedora 28

    Upgrade Fedora: A Step-by-Step Tutorial

    How to Install Postgres on MacOS

    How To Install PostgreSQL on MacOS

    How To Install Apache Solr on Fedora

    How To Install Apache Solr 9.0 on Fedora 36/35

    View 5 Comments

    5 Comments

    1. nikhil on August 26, 2019 6:31 am

      great tutorial,

      This was awesome… Thanks a lot.. 😀

      Reply
    2. Pradeep on July 6, 2018 11:46 am

      Thanks for super steps.

      Reply
    3. tecadmin tecadmin on February 15, 2018 10:17 am

      To initialize on Centos 6:
      service postgresql-9.6 initdb

      Reply
    4. Narendra reddy Ganesana on July 15, 2016 11:23 am

      sudo service postgresql-9.4 initdb for initilizing database

      Reply
    5. Shreeniva on June 26, 2014 9:55 am

      Gr8 tutorial

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to List Manually Installed Packages in Ubuntu & Debian
    • 10 Bash Tricks Every Developer Should Know
    • How to Validate Email Address in JavaScript
    • Firewalld: Common Firewall Rules and Commands
    • 12 Apk Commands in Alpine Linux Package Management
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.