Home » Programming » Databases » How to Update PostgreSQL on Linux (Ubuntu/Debian/Arch/RedHat)

How to Update PostgreSQL on Linux (Ubuntu/Debian/Arch/RedHat)

This article will instruct you how to update the PostgreSQL database server on Linux – Redhat, Ubuntu, Debian, and Arch Linux.

If you’re looking to install PostgreSQL server on your Linux system, follow our instructions here.

Take Care, and Back Up!

Note that this article is about updating the PostgreSQL package from your software repository. This will not upgrade to the next major release. Before you do update, however check which version will be installed and ensure it is compatible with the software you are connecting to the database. Be sure to back up your data (preferably your whole system!) before upgrading so there are no unintended consequences and so that you can roll back if necessary.

Check out our article on exporting PostgreSQL data here.

Updating PostgreSQL on Debian and Ubuntu Linux

Whether you opted to install PostgreSQL on your Debian system using the default Debian software repository, or added the PostgreSQL repository and installed from there, the update process is the same – the package names just differ:

From the Default apt Repository

If you installed from the default apt repository, run:

sudo apt update
sudo apt upgrade postgresql-12

From the PostgreSQL apt Repository

If you installed from the PostgreSQL apt repository, run:

sudo apt update
sudo apt upgrade postgresql

Updating PostgreSQL on Arch Linux

To update PostgreSQL installed from the default Arch software repository, re-run the installation:

pacman -S postgresql

Updating PosgreSQL on Redhat/Centos/Fedora

Update PostgreSQL on Red Hat-based distributions by running the following commands.

On Fedora and Red Hat 8 run:

dnf update postgresql-server

Or on older versions of Red Hat (6/7) run:

yum update postgresql-server

Updating PostgreSQL on Other Linux Distributions

If you have installed from source, you should just be able to install the next minor release and remain compatible with your existing data, but again, it’s always a good idea to back up first.

To continue your PostgreSQL journey, head back to our index that lists our full PostgreSQL guide.

SHARE:
Photo of author
Author
I'm Brad, and I'm nearing 20 years of experience with Linux. I've worked in just about every IT role there is before taking the leap into software development. Currently, I'm building desktop and web-based solutions with NodeJS and PHP hosted on Linux infrastructure. Visit my blog or find me on Twitter to see what I'm up to.

Leave a Comment