Install PostgreSQL 12 + PostGIS on Ubuntu 20.4 in 5 mins.

This article is a very short tutorial for installing PostgreSQL 12/ PostGIS on the Ubuntu system. It is a production note which I initially wrote for myself to install PostgreSQL on several machines. The explanation is kept very short and straight to the result.

Step 1: Add and Install the PostgreSQL 12 via your terminal.

$ sudo apt update
$ sudo apt install postgresql-12 postgresql-client-12

Step 2: Test PostgreSQL + Assign password to postgres

$ systemctl status postgresql.service

Then, connect and change the “postgres” password.

$ sudo -u postgres psql
$ \password postgres
enter strong password twice!

Step 3: Install GnuPG 2.0 and PostGIS

$ sudo sudo apt install gnupg2
$ sudo apt install postgis postgresql-12-postgis-3

Step 4: Set the Client Authentication & Connection

# ========================================
# === Set Listening Port =================
# ========================================
$ nano /etc/postgresql/12/main/postgresql.conf
# listen_addresses = '*' ==> Listen on all interfaces
# listen_addresses = '<ip here>'==> Listen on specified IP address
# ========================================
# === Set Client authentication ==========
# ========================================
$ nano /etc/postgresql/12/main/pg_hba.conf
# host postgres all md5

Step 5: Connect and enjoy PostgreSQL via your favorite GUI!

That’s about it! Enjoy Databasing!

M.Sc. in Photogrammetry and Geoinformatics. 📚LinkedIn: https://www.linkedin.com/in/thunyatheps/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store