Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Linux Distributions»CentOS»Installing PostgreSQL 9.1 on CentOS 5/6 and RHEL 5/6

    Installing PostgreSQL 9.1 on CentOS 5/6 and RHEL 5/6

    RahulBy RahulApril 8, 20133 Mins Read

    PostgreSQL is a open source object-relational, highly scalable, SQL compliant database management system. This article will help you for installing PostgreSQL 9.1 on CentOS 5/6 and RHEL 5/6.

    Step 1: Add PostgreSQL Yum Repository

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

    CentOS/RHEL 5, 32-Bit:
    #  rpm -Uvh http://yum.postgresql.org/9.1/redhat/rhel-5-i386/pgdg-centos91-9.1-4.noarch.rpm
    
    CentOS/RHEL 6, 32-Bit:
    #  rpm -Uvh http://yum.postgresql.org/9.1/redhat/rhel-6-i386/pgdg-centos91-9.1-4.noarch.rpm
    
    CentOS/RHEL 5, 64-Bit:
    #  rpm -Uvh http://yum.postgresql.org/9.1/redhat/rhel-5.0-x86_64//pgdg-centos91-9.1-4.noarch.rpm
    
    CentOS/RHEL 6, 64-Bit:
    #  rpm -Uvh http://yum.postgresql.org/9.1/redhat/rhel-6.3-x86_64/pgdg-centos91-9.1-4.noarch.rpm
    
    Step 2: Install PostgreSQL Server 9.1 using Yum.

    Below command will install PostgreSQL 9.1 on your system.

    # yum install postgresql91-server
    

    Sample Output

    Loaded plugins: fastestmirror, refresh-packagekit, security
    Loading mirror speeds from cached hostfile
     * base: ftp.iitm.ac.in
     * epel: mirror.yourconnect.com
     * extras: ftp.iitm.ac.in
     * updates: ftp.iitm.ac.in
    Setting up Install Process
    Resolving Dependencies
    --> Running transaction check
    ---> Package postgresql91-server.i686 0:9.1.9-1PGDG.rhel6 will be installed
    --> Processing Dependency: postgresql91 = 9.1.9-1PGDG.rhel6 for package: postgresql91-server-9.1.9-1PGDG.rhel6.i686
    --> Processing Dependency: libpq.so.5 for package: postgresql91-server-9.1.9-1PGDG.rhel6.i686
    --> Running transaction check
    ---> Package postgresql91.i686 0:9.1.9-1PGDG.rhel6 will be installed
    ---> Package postgresql91-libs.i686 0:9.1.9-1PGDG.rhel6 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ====================================================================================================
     Package                       Arch           Version                        Repository        Size
    ====================================================================================================
    Installing:
     postgresql91-server           i686           9.1.9-1PGDG.rhel6              pgdg91           3.6 M
    Installing for dependencies:
     postgresql91                  i686           9.1.9-1PGDG.rhel6              pgdg91           973 k
     postgresql91-libs             i686           9.1.9-1PGDG.rhel6              pgdg91           192 k
    
    Transaction Summary
    ====================================================================================================
    Install       3 Package(s)
    
    Total download size: 4.7 M
    Installed size: 20 M
    Is this ok [y/N]: y
    Downloading Packages:
    (1/3): postgresql91-9.1.9-1PGDG.rhel6.i686.rpm                               | 973 kB     00:02
    (2/3): postgresql91-libs-9.1.9-1PGDG.rhel6.i686.rpm                          | 192 kB     00:02
    (3/3): postgresql91-server-9.1.9-1PGDG.rhel6.i686.rpm                        | 3.6 MB     00:07
    ----------------------------------------------------------------------------------------------------
    Total                                                               321 kB/s | 4.7 MB     00:15
    Running rpm_check_debug
    Running Transaction Test
    Transaction Test Succeeded
    Running Transaction
    Warning: RPMDB altered outside of yum.
      Installing : postgresql91-libs-9.1.9-1PGDG.rhel6.i686                                         1/3
      Installing : postgresql91-9.1.9-1PGDG.rhel6.i686                                              2/3
      Installing : postgresql91-server-9.1.9-1PGDG.rhel6.i686                                       3/3
    
    Installed:
      postgresql91-server.i686 0:9.1.9-1PGDG.rhel6
    
    Dependency Installed:
      postgresql91.i686 0:9.1.9-1PGDG.rhel6          postgresql91-libs.i686 0:9.1.9-1PGDG.rhel6
    
    Complete!
    
    Step 3: Initialize PGDATA first time after Installation

    After installing PosgreSQL server, Its required to initialize it before using first time. To initialize database use below command.

    # /etc/init.d/postgresql-9.1 initdb
    

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

    PostgreSQL data directory Path

    /var/lib/pgsql/9.1/data/
    

    Older version ( PostgreSQL 7 or 8 ) uses below path by default for data directory.

    /var/lib/pgsql/data/
    
    Step 4: Start PostgreSQL Server

    Start postgresql service using following command.

    # service postgresql-9.1 start
    

    Setup PostgreSQL service to auto start on system boot.

    # chkconfig postgresql-9.1 on
    
    Step 5: Access PostgreSQL admin command prompt.

    To access postgres as admin user, first switch to postgres system account.

    # su - postgres
    

    Use psql command to access postgres prompt with admin priviledges.

    $ psql
    

    Sample output:

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

    Read below article to to how to install phpPgAdmin.

    >> How to Install phpPgAdmin on CentOS using Yum

    Thanks for using this tutorial for installting PostgreSQL 9.1 on CentOS 5/6 and RHEL 5/6 systems.

    pgsql postgres PostgreSQL psql
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleConfigure RNDC Key for Bind9 ( DNS Server )
    Next Article File Encryption using GPG Command Line in Linux

    Related Posts

    How To Configure PostgreSQL to Allow Remote Connections

    3 Mins Read

    How to Check the PostgreSQL Version

    Updated:August 6, 20212 Mins Read

    How to Install pgAdmin4 on Ubuntu 20.04

    Updated:April 9, 20214 Mins Read

    How to Install PostgreSQL and pgAdmin4 in Ubuntu 20.04

    Updated:July 1, 20215 Mins Read

    How to Install Let’s Encrypt (Certbot) on CentOS 8

    Updated:May 27, 20223 Mins Read

    How To Install Memcached on CentOS/RHEL 8

    Updated:August 8, 20201 Min Read

    1 Comment

    1. Anup Nair on May 7, 2014 10:03 am

      Rahul

      Thank you for this neat document on getting PgSql up and running.

      Reply

    Leave A Reply Cancel Reply

    Recent Posts
    • How to run “npm start” through docker
    • Filesystem Hierarchy Structure (FHS) in Linux
    • How to accept user input in Python
    • What is difference between var, let and const in JavaScript?
    • What is CPU? – Definition, Types and Parts
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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