Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Ubuntu 18.04 - Install PostgreSQL

Postgresql 10 has been out for a while now. One of the features that was added that I'm pretty keen on is better support for parallel queries which is worth migrating away from MySQL for.

Similar Posts


Run the following commands in order to add the PostgreSQL repository to Ubuntu 18.04

sudo apt update && sudo apt install gnupg2
echo 'deb bionic-pgdg main' | sudo tee /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - | sudo apt-key add -
sudo apt-get update

Install PostgreSQL Client

Now to install the client only (in order to connect to remote databases), run the following command:

sudo apt-get install postgresql-client-12 -y

If you want PostgreSQL 11 instead, just use this instead:

sudo apt-get install postgresql-client-11 -y

Install Server

If you wish to run a PostgreSQL server instead, run the following command:

sudo apt-get install postgresql-12 -y

If you want version 11 instead, use:

sudo apt-get install postgresql-11 -y

Check Version

If you want to check what version of PostgreSQL you are now running, use the following command:

sudo -u postgres psql postgres -c 'SELECT version()' | grep PostgreSQL

Configure It

After having installed PostgreSQL, you probably want to spend a bit of time configuring it (passwords etc).


Last updated: 3rd September 2023
First published: 7th October 2019