Install PostgreSQL 9.5 on CentOS/RHEL 7/6/5

PostgreSQL 9.5 Released. PostgreSQL is developed at the University of California at Berkeley Computer Science Department. PostgreSQL is a free, open-source object-relational database management system (object-RDBMS), like MySQL. It is a prevalent decision for some little and vast projects and has the benefit of being standards-compliant and having numerous features like reliable transactions and concurrency without read locks.
Install PostgreSQL

See Also:

  • Install PostgreSQL 9.5 on Ubuntu 15.10, 14.04 & 12.04
  • Step #1 Adding PostgreSQL Yum Repository

    First install PostgreSQL repository in your system, Use one of below commands as per your operating system.

    For CentOS/RHEL 7
    # rpm -Uvh http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm
    For CentOS/RHEL 6
    # rpm -Uvh http://yum.postgresql.org/9.5/redhat/rhel-6-x86_64/pgdg-redhat95-9.5-2.noarch.rpm
    For CentOS/RHEL 5
    # rpm -Uvh http://yum.postgresql.org/9.5/redhat/rhel-5-x86_64/pgdg-redhat95-9.5-2.noarch.rpm
    

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

    Step #2 Install PostgreSQL Server

    After adding PostgreSQL yum repository in your system use following command to install PostgreSQL 9.5 on your system.

    # yum install postgresql95-server postgresql95
    

    Step #3 Initializing PGDATA

    After installing PostgreSQL server, It’s required to initialize database. To initialize database use below command.

    # /usr/pgsql-9.5/bin/postgresql95-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/9.5/data/
    

    Step #4 Start PostgreSQL Server

    Use below command to start PostgreSQL service. Also enable PostgreSQL service to auto start on system boot.

    For CentOS/RHEL 7
    # systemctl start postgresql-9.5
    # systemctl enable postgresql-9.5
    For CentOS/RHEL 6/5
    # service  postgresql-9.5 start
    # chkconfig postgresql-9.5 on
    

    Step #5 Set Postgres User Password

    Follow below steps to set postgresQL password:

    # su - postgres
    

    Use psql command to access PostgreSQL prompt with admin privileges.

    $ psql
    
    psql (9.5.1)
    Type "help" for help.
    
    postgres=#
    

    You may create password for user postgres for security purpose.

    postgres=# \password postgres
    

    You have successfully installed PostgreSQL Server.

    Enjoy it!

    Comments
    1. 4 years ago

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

    The reCAPTCHA verification period has expired. Please reload the page.