Skip to content

~/avetyan.com/blog

Guide Blog

How To Install PostgreSQL 16 on Ubuntu 22.04

Install PostgreSQL 16 from the official PGDG repository on Ubuntu 22.04, without the deprecated apt-key.

Published 1 min read

How To Install PostgreSQL 16 on Ubuntu 22.04

If you want to install the latest version of Postgres on Ubuntu, you may have tried the script from the Postgres website. It warns that apt-key is deprecated, and so I don’t have to modify the script every time, I decided to write it down here.

install-postgresql-16.sh
# Install the prerequisites:
sudo apt install curl gnupg2 ca-certificates lsb-release ubuntu-keyring

# Import the repository signing key:
curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor \
 | sudo tee /usr/share/keyrings/postgresql-archive-keyring.gpg >/dev/null

# Create the file repository configuration:
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/postgresql-archive-keyring.gpg] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

# Update the package lists:
sudo apt update

# Install the latest version of PostgreSQL.
# Or any other version:
sudo apt -y install postgresql-16 postgresql-client-16

Comments

Comment as a guest, or sign in with Google, GitHub or Facebook. How your data is handled.

Loading comments…