Skip to content

Instantly share code, notes, and snippets.

@karlrwjohnson
Last active March 8, 2023 14:16
Show Gist options
  • Save karlrwjohnson/30208cfa13f5b9ed07ef8eec02b9ca4d to your computer and use it in GitHub Desktop.
Save karlrwjohnson/30208cfa13f5b9ed07ef8eec02b9ca4d to your computer and use it in GitHub Desktop.
Installing latest Postgres on Ubuntu
  • Currently Ubuntu ships with Postgres 12. At time of writing, Postgres 15 is available.
  • If you follow the Ubuntu instructions, APT will log a message that "apt-key is deprecated" every time you check for updates.

This is how to do it right.

Based on information here:

# Add the Postgres keyring USING A SEPARATE SIGNING KEY FILE
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/postgres-archive-keyring.gpg] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

# Download Postgre' signing key INTO ITS OWN FILE
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc \
| gpg --dearmor \
| sudo tee /usr/share/keyrings/postgres-archive-keyring.gpg

# Update the package lists:
sudo apt-get update

# Install the latest version of PostgreSQL.
# If you want a specific version, use 'postgresql-12' or similar instead of 'postgresql':
sudo apt-get -y install postgresql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment