How To Install PostgreSQL 12 on Ubuntu 20.04

January 7, 2021 in Tutorial2 minutes

Introduction

In this tutorial, we learn how to install PostgreSQL 12 on Ubuntu 20.04 (Focal Fossa). PostgreSQL, or usually called Postgres, is an open-source object-relational database management system (ORDBMS) with an emphasis on extensibility and standards compliance. PostgreSQL is ACID-compliant and transactional. It is developed by PostgreSQL Global Development Group (PGDG) that consists of many companies and individual contributors. PostgreSQL released under the terms of PostgreSQL license. PostgreSQL 12 was released on 18 October 2018. Major enhancements in PostgreSQL 12 includes:

  • Increased Robustness and Performance for Partitioning
  • Transactions Supported in Stored Procedures
  • Enhanced Capabilities for Query Parallelism
  • Just-in-Time (JIT) Compilation for Expressions
  • General User Experience Improvements

Prerequisites

This tutorial assume you already satisfy the following requirements:

  • A machine with fresh install of Ubuntu Server 20.04. It can be A virtual machine locally using Virtualbox, VMWare workstation or VMWare Fusion, KVM, Xen, or a virtual machine in the cloud like [DigitalOcean][1] or [Linode][2].
  • A non-root user with sudo privileges or a root user access. If you’re usig root user remove sudo from each command on this tutorial.

Step 1 — Update Base Systems

Since this is a fresh install of Ubuntu Server 20.04, before we install PostgreSQL 12, let’s update our system to the latest update.

sudo apt-get update
sudo apt-get -y upgrade

After we upgrade our base system, now it’s time to install PostgreSQL 12. Since Ubuntu 20.04 doesn’t have PostgreSQL 12 in [its repository][3], we need to add oficial PostgreSQL repository so we can install PostgreSQL 12.

Step 2 — Import Repository Signing Key

The PostgreSQL team is using GPG to sign downloadable packages from the PostgreSQL website. We add PostgreSQL public GPG key so … [truncated]