Ubuntu 20.04 - Install PostgreSQL
Similar Posts
Native Package - PostgreSQL 12
sudo apt update \
&& sudo apt install postgresql-12
PostgreSQL Repository
If you want to install the very latest version of PostgreSQL (current PostgreSQL 13), then you will need to add their repository which can be done with the script below:
# Create the file repository configuration:
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
# Import the repository signing key:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
# Update the package lists:
sudo apt-get update
... then you can install whichever version you want, including version 13.
sudo apt-get -y install postgresql-13
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).
References
- PostgreSQL Docs - Linux downloads (Ubuntu)
- Stack Overflow - Which version of PostgreSQL am I running?
Last updated: 3rd September 2023
First published: 23rd October 2020
First published: 23rd October 2020