Installing PostgreSQL on Linux
This page demonstrates how the different PostgreSQL versions can be installed on Linux Operating System.
CentOS 7
Ubuntu
In the official PostgreSQL APT repository, version 12.6 is not available.
Ubuntu 12
To install,
1. the official PostgreSQL 12 repository key needs to be added:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
2. the repository is to be added:
echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" |sudo tee /etc/apt/sources.list.d/pgdg.list
3. the package needs to be updated and added in the following pattern: sudo apt install <package_name>=<version>
sudo apt -y update; sudo apt -y install postgresql-12=12.2-4
To check with the version, a specific distribution use is available
apt-cache policy postgresql-12
Ubuntu 18.04
- https://apt-archive.postgresql.org/ to be used
- The below line needs to be added to /etc/apt/sources.list.d/pgarchive.list
deb https://apt-archive.postgresql.org/pub/repos/apt bionic-pgdg-archive main
apt-cache policy postgresql-12
postgresql-12:
Installed: (none)
Candidate: 12.10-1.pgdg20.04+1
Version table:
12.10-1.pgdg20.04+1 500
500 http://apt.postgresql.org/pub/repos/apt focal-pgdg/main amd64 Packages
12.10-1.pgdg18.04+1 500
500 https://apt-archive.postgresql.org/pub/repos/apt bionic-pgdg-archive/main amd64 Packages
12.9-1.pgdg18.04+1 500
500 https://apt-archive.postgresql.org/pub/repos/apt bionic-pgdg-archive/main amd64 Packages
12.9-0ubuntu0.20.04.1 500
500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
500 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
12.8-1.pgdg18.04+1 500
500 https://apt-archive.postgresql.org/pub/repos/apt bionic-pgdg-archive/main amd64 Packages
12.7-1.pgdg18.04+1 500
500 https://apt-archive.postgresql.org/pub/repos/apt bionic-pgdg-archive/main amd64 Packages
12.6-1.pgdg18.04+1 500
500 https://apt-archive.postgresql.org/pub/repos/apt bionic-pgdg-archive/main amd64 Packages
12.5-1.pgdg18.04+1 500
500 https://apt-archive.postgresql.org/pub/repos/apt bionic-pgdg-archive/main amd64 Packages
12.4-1.pgdg18.04+1 500
500 https://apt-archive.postgresql.org/pub/repos/apt bionic-pgdg-archive/main amd64 Packages
12.3-1.pgdg18.04+1 500
500 https://apt-archive.postgresql.org/pub/repos/apt bionic-pgdg-archive/main amd64 Packages
12.2-4 500
500 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages
12.2-2.pgdg18.04+1 500
500 https://apt-archive.postgresql.org/pub/repos/apt bionic-pgdg-archive/main amd64 Packages
12.2-1.pgdg18.04+1 500
500 https://apt-archive.postgresql.org/pub/repos/apt bionic-pgdg-archive/main amd64 Packages
12.1-2.pgdg18.04+1 500
500 https://apt-archive.postgresql.org/pub/repos/apt bionic-pgdg-archive/main amd64 Packages
12.1-1.pgdg18.04+1 500
500 https://apt-archive.postgresql.org/pub/repos/apt bionic-pgdg-archive/main amd64 Packages
12.0-2.pgdg18.04+1 500
500 https://apt-archive.postgresql.org/pub/repos/apt bionic-pgdg-archive/main amd64 Packages
12.0-1.pgdg18.04+1 500
500 https://apt-archive.postgresql.org/pub/repos/apt bionic-pgdg-archive/main amd64 Packages
12~rc1-1.pgdg18.04+1 500
500 https://apt-archive.postgresql.org/pub/repos/apt bionic-pgdg-archive/main amd64 Packages
12~beta4-1.pgdg18.04+1 500
500 https://apt-archive.postgresql.org/pub/repos/apt bionic-pgdg-archive/main amd64 Packages
12~beta3-1.pgdg18.04+1 500
500 https://apt-archive.postgresql.org/pub/repos/apt bionic-pgdg-archive/main amd64 Packages
12~beta2-1.pgdg18.04+1 500
500 https://apt-archive.postgresql.org/pub/repos/apt bionic-pgdg-archive/main amd64 Packages
12~beta1-1.pgdg18.04+1 500
500 https://apt-archive.postgresql.org/pub/repos/apt bionic-pgdg-archive/main amd64 Packages
Ubuntu 20.04
The various Operating Systems handle the package versions differently during installation:
- RHEL based: <pacakge_name>-<version>
- Debian based: <pacakge_name>=<version>
See also: Preparing PostgreSQL Database