How to Install PostgreSQL in Ubuntu 20.04 on Multipass Instance

juandisay
5 min readApr 7, 2021

PostgreSQL is a powerful, reliable, robust and open source object-relational database system.

The latest version of this database system is PostgreSQL 13.2, while versions 12.6, 11.11, 10.16, 9.6.21, & 9.5.25 still getting the regular updates.

This tutorial describe you to how to install the newest PostgreSQL on Ubuntu 20.04 LTS Linux system.

Prerequisites

A running Ubuntu 20.04 LTS system with shell access.

Login as a sudo user and press “CTRL+ALT+T” to open a terminal. Then install few required packages.

sudo apt update sudo apt install wget curl ca-certificates

Step 1 — Install PostgreSQL in Ubuntu 20.04

First of all, Import the repository signing GPG key to your system. Open a terminal and use below command to import key:

wget -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

Next, create a PPA file for PostgreSQL on your Ubuntu 20.04 system.

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ focal-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'

After adding the PPA to your system. Execute the following command to install PostgreSQL server on your system.

sudo apt update sudo apt-get install postgresql postgresql-contrib

Press ‘y’ for any confirmation prompted by the installer. The above command will install latest version of PostgreSQL server on your Ubuntu system.

After successful installation verify the postgresql service:

sudo systemctl status postgresql

Step 2 — Connection To PostgreSQL

Now, establish a connection with the newly installed Postgres database server. First switch to the system’s postgres user account:

sudo su - postgres

then type “psql” to get the postgress prompt:

psql  psql (13.2 (Ubuntu 13.2-1.pgdg20.04+1)) Type "help" for help. postgres=#

--

--