![]() |
VOOZH | about |
This is a step-by-step guide to install PostgreSQL on a Linux machine. By default, PostgreSQL is available in all Ubuntu versions as PostgreSql "Snapshot". However other versions of the same can be downloaded through the PostgreSQL apt repository.
We will be installing PostgreSQL version 11.3 on Ubuntu in this article.
There are three crucial steps for the installation of PostgreSQL as follows:
You can check for the current version of PostgreSQL on your Ubuntu device by using the below command in the terminal:
postgres -V
After checking if you need an update of PostgreSQL, follow the below steps to install the latest PostgreSQL version:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
sudo apt update sudo apt install postgresql postgresql-contrib
There are couple of ways to verify the installation of PostgreSQL like connecting to the database server using some client applications like pgAdmin or psql.
The quickest way though is to use the psql shell. For that follow the below steps:
sudo su postgres
psql
SELECT version();