Score:5

How to upgrade PostgreSQL from 14 to 15 on Ubuntu 22.04?

es flag

I have Ubuntu 22.04. I currently have PostgreSQL 14.6. I want to upgrade PostgreSQL to 15. I tried running:

sudo apt-get update && sudo apt install postgresql

but I got the following message:

...
postgresql is already the newest version (14+238.pgdg21.04+1).

How do I upgrade PostgreSQL from 14 to 15 on Ubuntu 22.04?

Score:5
es flag

PostgreSQL 15 is not available in the default package repository. To install PostgreSQL >= 15, you need to add an additional APT repository to /etc/apt/sources.list.d/.

In order to do so, run:

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/trusted.gpg.d/pgdg.asc &>/dev/null

Then,

sudo apt update
sudo apt install postgresql

It worked:

$ psql --version
psql (PostgreSQL) 15.2 (Ubuntu 15.2-1.pgdg22.04+1)

Source: https://www.linuxtechi.com/how-to-install-postgresql-on-ubuntu/

ru flag
If I may make a suggestion, it's generally considered poor form to use `trusted.gpg.d` to define trusted keys, and instead to make `/etc/apt/keyrings`, store the PGP keys there, and then add a source with the signed key of `deb [signed-by=/etc/apt/keyrings/FILENAME] ...` instead nowadays, which defers from the 'guides' but makes things a little more 'secure' (so that the pgp key for the PSQL repos can't be used to sign *other* repos)
Score:0
mr flag

Or, alternately, as noted by Thomas Ward -On Strike, if you would want to do it the secure way, you could simply run this script provided from PostgreSQL itself.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.