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

    How to Install PostgreSQL 11 on CentOS/RHEL 7/6

    By RahulJune 26, 20212 Mins Read

    PostgreSQL 11 Released. It 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 11 on CentOS/RHEL 7/6 system.

    Advertisement

    This article has been tested on CentOS Linux release 7.5

    Step 1 – Configure Yum Repository

    Firstly you need to configure the PostgreSQL repository in your system. Use one of the below commands as per your operating system version.

    sudo yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
    

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

    Step 2 – Installing PostgreSQL on CentOS 7

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

    yum install postgresql11-server
    

    This will also install some additional required packages on your system. Enter y to confirm and complete the installation process.

    Install PostgreSQL 11 on CentOS

    Step 3 – Initialize PGDATA

    After that, you need to initialize the PostgreSQL instance. In other words, this will create a data directory and other configuration files on your system. To initialize the database use the below command.

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

    Initialize PostgreSQL 11 on CentOS

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

    PostgreSQL 11 default data directory location is /var/lib/pgsql/11/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.

    systemctl enable postgresql-11.service
    systemctl start postgresql-11.service
    

    Step 5 – Verify PostgreSQL Installation

    After completing the above all steps. Your PostgreSQL 11 server is ready to use. Log in to your server to verify the connection.

    su - postgres -c "psql"
    
    psql (11.0)
    Type "help" for help.
    
    postgres=# 
    

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

    postgres=# \password postgres
    

    In conclusion, You have successfully installed the PostgreSQL database server on CentOS/RHEL 7 system.

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

    Related Posts

    How to Install Postgres on MacOS

    How To Install PostgreSQL on MacOS

    How to Allow Remote Connections in Postgres

    How To Configure PostgreSQL to Allow Remote Connections

    Check the PostgreSQL Version

    How to Check the PostgreSQL Version

    View 9 Comments

    9 Comments

    1. Titas uddin on April 25, 2021 7:03 am

      Installed perfectly. But pg_dump version mismatch. i found pg_dump version 9.2 installed on my server.

      How can I upgrade pg_dump version to 11.6

      Thanks,

      Reply
    2. Héctor Uriel on June 24, 2019 2:26 am

      Hi Rahul!

      I’ve been traying several ways to chance the data directory in postgresql-11 and I still can’t!, could you tell me how to do that?

      Thanks in advance!

      Reply
    3. RadekTester on June 7, 2019 8:16 am

      Hi Guys,

      It does not work for me… when I try to do:

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

      I’m getting the following:
      /usr/pgsql-11/bin/postgresql-11-setup: No such file or directory

      it looks that I don’t have this postgresql-11-setup file.
      List of files in /usr/pgsql-11/bin/ is:
      ls -l /usr/pgsql-11/bin/
      total 9760
      -rwxr-xr-x. 1 root root 53328 May 8 10:19 clusterdb
      -rwxr-xr-x. 1 root root 53136 May 8 10:19 createdb
      -rwxr-xr-x. 1 root root 57464 May 8 10:19 createuser
      -rwxr-xr-x. 1 root root 48944 May 8 10:19 dropdb
      -rwxr-xr-x. 1 root root 48944 May 8 10:19 dropuser
      -rwxr-xr-x. 1 root root 119440 May 8 10:19 initdb
      -rwxr-xr-x. 1 root root 23552 May 8 10:19 pg_archivecleanup
      -rwxr-xr-x. 1 root root 108296 May 8 10:19 pg_basebackup
      -rwxr-xr-x. 1 root root 140152 May 8 10:19 pgbench
      -rwxr-xr-x. 1 root root 27528 May 8 10:19 pg_config
      -rwxr-xr-x. 1 root root 37528 May 8 10:19 pg_controldata
      -rwxr-xr-x. 1 root root 52800 May 8 10:19 pg_ctl
      -rwxr-xr-x. 1 root root 392896 May 8 10:19 pg_dump
      -rwxr-xr-x. 1 root root 84984 May 8 10:19 pg_dumpall
      -rwxr-xr-x. 1 root root 49400 May 8 10:19 pg_isready
      -rwxr-xr-x. 1 root root 67520 May 8 10:19 pg_receivewal
      -rwxr-xr-x. 1 root root 48680 May 8 10:19 pg_resetwal
      -rwxr-xr-x. 1 root root 155472 May 8 10:19 pg_restore
      -rwxr-xr-x. 1 root root 79360 May 8 10:19 pg_rewind
      -rwxr-xr-x. 1 root root 27824 May 8 10:19 pg_test_fsync
      -rwxr-xr-x. 1 root root 21616 May 8 10:19 pg_test_timing
      -rwxr-xr-x. 1 root root 122880 May 8 10:19 pg_upgrade
      -rwxr-xr-x. 1 root root 35968 May 8 10:19 pg_verify_checksums
      -rwxr-xr-x. 1 root root 77600 May 8 10:19 pg_waldump
      -rwxr-xr-x. 1 root root 7290872 May 8 10:19 postgres
      lrwxrwxrwx. 1 root root 8 Jun 7 10:05 postmaster -> postgres
      -rwxr-xr-x. 1 root root 608784 May 8 10:19 psql
      -rwxr-xr-x. 1 root root 57104 May 8 10:19 reindexdb
      -rwxr-xr-x. 1 root root 61392 May 8 10:19 vacuumdb

      Reply
      • Ildar on August 8, 2019 1:37 pm

        If “/usr/pgsql-11/bin/postgresql-11-setup initdb” – /usr/pgsql-11/bin/postgresql-11-setup: No such file or directory
        Then use “service postgresql-11 initdb” to initialize the cluster first.

        On centos6 works for me.

        Reply
    4. Ishan on May 27, 2019 11:28 am

      Hi Rahul,
      This are the perfect steps to install in Redhat Linux 7.
      As I am new to postgres, I have question regarding installation location of postgres. Can we change/install it some user manage path in some filesystem or it is default install in /var/lib/… ?

      Reply
    5. JavaForEver on May 4, 2019 8:26 pm

      Thank you Rahul

      Reply
    6. Igor on April 12, 2019 7:17 am

      Wrong link
      https://yum.postgresql.org/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm

      404 – Not Found

      Reply
    7. Pawelan on February 6, 2019 1:03 pm

      Thanks for providing this Rahul.
      As the extension, for RedHat 7 systems connected to subscription-manager, it might be useful to exclude PostgreSQL packages from other repositories just to prevent accidental installation of older version dependencies. You can check which packages are available with the following command:
      yum list postgresql*
      and exclude them from listed repositories with:
      subscription-manager repo-override –repo=rhel-7-server-rpms –repo=rhel-7-server-optional-rpms –add=exclude:’postgresql*’
      For manually added repository it is enough to add “exclude=postgresql*” to /etc/yum.repos.d/XYZ.repo file.

      Reply
    8. dominic on January 24, 2019 6:33 pm

      This worked flawlessly. I’ve been using pgsql for years but getting 11.x installed on Linux has proven…difficult. Thanks Rahul.

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to Split Large Archives in Linux using the Command Line
    • System.out.println() Method in Java: A Beginner’s Guide
    • Split Command in Linux With Examples (Split Large Files)
    • Test Your Internet Speed from the Linux Terminal
    • 11 Practical Example of cat Command in Linux
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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