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 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-16Comments
Sign in with Google, GitHub or Facebook to comment.
Loading comments…