Skip to main content

Upgrading or Updating MariaDB on AlmaLinux 9

What

This article provides a step-by-step guide to upgrading or updating MariaDB on AlmaLinux 9. MariaDB is a popular open-source database management system. Updating to the latest version will ensure optimal performance, security, and compatibility.

When/Why

Updating or upgrading MariaDB on AlmaLinux 9 should be performed when a newer version is available, to improve database operations, add new features, or patch potential vulnerabilities.

How

1. Check Current MariaDB Version on AlmaLinux 9

Check the current MariaDB version and AlmaLinux OS version using the following commands:

mysql -V
cat /etc/almalinux-release

2. Create a Backup of Existing MariaDB Databases

Create a backup of existing databases:

mysqldump -u root -p --all-databases > /tmp/database-backup.sql
cp -a /var/lib/mysql /var/lib/mysql.backup
cp -a /etc/my.cnf /etc/my.cnf_bk

3. Uninstall Old MariaDB Repositories

Uninstall the old MariaDB repositories:

systemctl stop mariadb
mv /etc/yum.repos.d/mariadb.repo /etc/yum.repos.d/mariadb_bk
dnf update

4. Add the new MariaDB Repository on AlmaLinux 9

Create a new repo file for the latest version:

vi /etc/yum.repos.d/MariaDB.repo

Paste the following contents into the file:

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.11/rhel9-amd64
module_hotfixes=1
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1 

5. Remove Old MariaDB Server

Remove the old MariaDB version:

dnf remove mariadb-server
dnf clean all

6. Upgrade and Install Latest MariaDB

Install the latest version of MariaDB on your server:

dnf install MariaDB-server
dnf install MariaDB-server galera-4 MariaDB-client MariaDB-shared MariaDB-backup MariaDB-common
systemctl start mariadb
systemctl enable mariadb
mysql_upgrade -u root -p

Verify your MariaDB version and status:

mysql -V
systemctl status mariadb