Upgrade to MariaDB 10.6 on Ubuntu 20.04 – Najigram.com

This article is not only about upgrading, but also about how to back up and restore your databases in the process. Ubuntu 20.04 has MariaDB 10.3 as the default package in the repository. Updating isn’t difficult, but when it comes to data, it’s always best to avoid such things unless necessary. Today I am going to show you how to upgrade to MariaDB 10.6 on Ubuntu 20.04 and backup-restore databases in the process.

What We’ll Cover:

  • Foundations
  • Upgrading to MariaDB 10.6
  • Restore Databases

I want to clarify one point here, it’s not even really necessary to back up your data

, but as I always say “Back up your data even if you don’t need it “. This is because when you upgrade to another version, the database directory remains intact and is not deleted in this process.

If you want to know which versions are currently available in the repositories.

apt-cache show mariadb-server | Grep version

Install some basic and required packages

. sudo apt install mariadb-backup wget curl Backup Databases

I’m going to show you two ways to

back up

your databases. 1- mysqldump I have already written a detailed article on how to backup databases with mysqldump

. This is useful if you have one or two databases. But if you have a large set of databases to manage, go to step 2.

2- MariaBackup

This part takes care of all databases and data in one command

. sudo mariabackup -backup -user=root -password= -target-dir=/home/mian/mariadb_full_backup Change –

user, -password to your actual database administrator username/password. -target-dir is where the data will be stored. Change this path accordingly.

Now, if you want to prepare this data backup to restore after the upgrade, just run the following command.

sudo mariabackup -prepare-use-memory=34359738368-target-dir=/home/mian/mariadb_full_backup Refer to restore step

2 below to know how to restore them

.

Upgrade to MariaDB 10.6

Check the status of the database and stop it if it is running

. sudo systemctl status mariadb sudo systemctl stop mariadb

Delete all current packages

. sudo apt remove mariadb-* galera-3

Download the bash script.

WGET https://downloads.mariadb.com/MariaDB/mariadb_repo_setup Echo “B9E90Cde27affc2A44F9FC60E302CCCFCACF71F4AE02071F30D570E6048C28597 mariadb_repo_setup” | sha256sum -c –

Make the script executable

. chmod +x mariadb_repo_setup Run the

script

. sudo ./mariadb_repo_setup -mariadb-server-version=”mariadb-10.6″ Install the

updated version now

. sudo apt update sudo apt install mariadb-server mariadb-backup

After installation, start the database server

. sudo systemctl start mariadb sudo systemctl enable mariadb

Check your version

. mariadb -V

This is pretty much all for the upgrade process

.

Restore

databases

At this point, you have all the databases and everything out there, but just in case you want to restore if you had a clean installation

.

1- mysql

Same as backup, you can find the restore part also in this article. Use the mysql tool to restore databases.

2- mariabackup

If you have backed up the databases using method 2 above. Use this step to restore them.

Stop the database server.

sudo systemctl stop mariadb Move the

current mysql

data directory. sudo mv /var/lib/mysql /var/lib/mysql-backup

Create a new director

. sudo mkdir /var/lib/mysql

Restore the data to this newly created directory

. sudo mariabackup -copy-back -target-dir=/home/mian/mariadb_full_backup

Change ownership

. sudo chown -r mysql:mysql /var/lib/mysql

Start the database server now.

sudo systemctl start mariadb

Contact US