Table of Contents
Was this article helpful?

1  out of  1 found this helpful

Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $600 by adding new articles.

Install PostgreSQL on CentOS 7

Author: Asineth Martin

Last Updated: Wed, Aug 11, 2021
CentOS PostgreSQL


PostgreSQL is one of the most advanced open source Relational Database Management Systems (RDBMS). It is ANSI SQL:2008 standards compliant and has gained more buzz lately due to its addition of JSON and JSONB native data types, causing it to be looked at as a viable solution to problems NoSQL databases, such as MongoDB, are traditionally used to solve.

Follow this guide to install PostgreSql on CentOS 7.



  1. Add the PostgreSQL repository.

    $ sudo yum install -y
  2. Install PostgreSQL.

    $ sudo yum install -y postgresql13-server
  3. Initialize the database.

    $ sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
  4. Enable and start the service.

    $ sudo systemctl enable --now postgresql-13


PostgreSQL creates a default user to access the psql shell.

  1. Switch to the user and execute a shell.

    $ sudo -iu postgres psql
  2. Create a database named test.

  3. Connect to the new database named test.

    $ \c test
  4. Create a table named messages.

    $ CREATE TABLE messages (handle VARCHAR(32), message VARCHAR(280));
  5. Insert a couple rows into the new table named messages.

    $ INSERT INTO messages VALUES ('User', 'This is a test message.');
    $ INSERT INTO messages VALUES ('User', 'This is another test message.');
  6. Query all rows from the table named messages.

    $ SELECT * FROM messages;

The rows inserted in the earlier steps should be listed.


PostgreSQL has many features that are available for use. Some of them include multi-version concurrency control (MVCC), point in time recovery, tablespaces, asynchronous replication, nested transactions (savepoints), online/hot backups, query planner/optimizer, and write ahead logging for fault tolerance. To get the most out of PostgreSQL, refer to the documentation.

Want to contribute?

You could earn up to $600 by adding new articles.