MariaDB is one of the most popular open-source databases next to its originator MySQL. The original creators of MySQL developed MariaDB in response to fears that MySQL will suddenly become a paid service due to Oracle acquiring it in 2010. With its history of doing similar tactics, the developers behind MariaDB have promised to keep it open source and free from such fears as what has happened to MySQL.
MariaDB has become just as popular as MySQL with developers, with features such as advanced clustering with Galera Cluster 4, faster cache/indexes, storage engines, and features/extensions that you won’t find in MySQL.
Today we will be talking about how to upgrade our version of MariaDB on Ubuntu 20.04 LTS manually. Currently, as of 23/05/2021, Ubuntu is on version 10.3.29 when we have available v10.5.10. Yes, we are a bit behind, not even being on v10.5 yet. Please be aware that upgrading to a newer version may break your existing apps, be sure to do some investigations first, but most of it should not cause problems.
Our guide already assumes you know how to set up the default MariaDB that ships with Ubuntu. This guide does not explain how to set it up for the first time but solely to keep up to date with the latest versions from MariaDB.
Before proceeding with this guide, quickly check if you have apt=transport-https installed by the following:
sudo apt install apt-transport-https -y
Back-up of our databases, perform your back-up routines and snapshots for extra safety. Next, we will back up our old MariaDB directory with the following command:
sudo mariadb-backup --backup \
Next, we must make sure the successful backup is consistent if we refer back to it. InnoDB will crash if it notices inconsistencies and crashes to protect you from a corrupt database. Before a database backup is trusted, it’s always wise to test it with the following command:
sudo mariadb-backup --prepare \
Once all confirmed we move to the upgrade section.
Remove Existing Versions of MariaDB
To install MariaDB 10.5+ we need to remove the original versions. We do so with the following:
First, need to stop MariaDB from its current option:
sudo systemctl stop mariadb
Second, remove MariaDB and all sources of your Ubuntu server.
sudo apt remove "mariadb-*"
Third, remove the Galera-4 package.
sudo apt remove galera-4
Fourth, confirm that all packages have been wiped:
apt list --installed | grep -i -E "mariadb|galera"
Download MariaDB Repo And Setup
Proceed into your nominated Download folder, and you do not need to download MariaDB 10.5 in any particular directory. Proceed as follows:
Download the official repo package and setup:
sudo wget https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
echo "b2064eff25a3553845ccb58dcb21b6a7dc83cebfe4815f33de37cf7e2a4bf165 mariadb_repo_setup" | sha256sum -c -
Next, we make it executable:
sudo chmod +x mariadb_repo_setup
A quick way to make sure permissions are correct is to type in your directory:
If correct should appear green with x on the end
Install MariaDB 10.5
Proceed to install the repo, which adds the necessary repository to your apt source list along with package signing keys.
sudo ./mariadb_repo_setup \ --mariadb-server-version="mariadb-10.5"
Optional – Install MariaDB 10.6 New Release
If you would like to install MariaDB 10.6 instead of the 10.5 you can do so by executing the following command:
sudo ./mariadb_repo_setup \ --mariadb-server-version="mariadb-10.6"
Now we finally get to the good part, installing MariaDB 10.5:
Check for updates:
sudo apt update && sudo apt full-upgrade -y
Proceed to install MariaDB 10.5:
sudo apt install mariadb-server mariadb-backup -y
You should see the packages list which, shows them all being 10.5 instead of 10.3
Proceed by hitting “Y” and once complete, you can check your version by the following:
Check the status of MariaDB by the following:
sudo systemctl status mariadb
If by some chance MariaDB has not started, do the following command.
sudo systemctl start mariadb
Next, make sure to enable it by default on startup/reboot:
sudo systemctl enable mariadb
Conclusion and Comments
MariaDB does invest in updates a fair bit. Some may be nervous about having the latest version on their servers; however, I run the latest versions of MariaDB on all my servers with no hassle or security issues, and they do frequent updates. That is the better part.
Overall as mentioned at the start of the guide, it’s always best to research if this may break your app, servers before making any decision for your server needs.