Share your love
Best Steps To Upgrade MariaDB on AlmaLinux 9

This guide intends to teach you to Update or Upgrade MariaDB on AlmaLinux 9. If you have a MariaDB running on your server but not in the latest version, you can follow this guide on the Orcacore website to update it to the latest version or the one you wish to use.
Table of Contents
Steps To Upgrade MariaDB on AlmaLinux 9
To Update MariaDB Version Linux, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide the Initial Server Setup with AlmaLinux 9.
Check the Current MariaDB Version on AlmaLinux 9
First, you must check the current MariaDB version and AlmaLinux OS version using the below commands:
mysql -V
Output
mysql Ver 15.1 Distrib 10.5.16-MariaDB, for Linux (x86_64) using EditLine wrapper
cat /etc/almalinux-release
Output
AlmaLinux release 9.2 (Turquoise Kodkod)
Create a Backup of Existing MariaDB Databases
Then, you must create a backup or a dump of the existing databases. To do this, run the following command:
mysqldump
-u root -p
--all-databases > /tmp/database-backup.sql
Next, copy the database directory into a separate folder with the following command:
cp -a /var/lib/mysql /var/lib/mysql.backup
Now you must back up the configuration file with the following command:
cp -a /etc/my.cnf /etc/my.cnf_bk
Note: In case of any failures in the upgrade, you can use one of the above copies to restore your databases.
Uninstall Old MariaDB Repositories
In this step, you need to uninstall the old MariaDB repositories. To do this, stop your MariaDB service on AlmaLinux 9:
systemctl stop mariadb
Verify that your service is stopped:
systemctl status mariadb

Move the current MariaDB repository with the following command:
mv /etc/yum.repos.d/mariadb.repo /etc/yum.repos.d/mariadb_bk
Then, update your local package index with the following command:
dnf update
Add the new MariaDB Repository on AlmaLinux 9
Next, you need to add the new MariaDB repository. To do this, create a new repo file for the latest version with your favorite text editor, here we use vi:
vi /etc/yum.repos.d/MariaDB.repo
Copy and 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
When you are done, save and close the file.
Remove the Old MariaDB Server
Now, you need to remove the MariaDB old version by using the command below on AlmaLinux 9:
dnf remove mariadb-server
Clean the repository cache:
dnf clean all
Upgrade and Install the Latest MariaDB
At this point, you can install the latest version of MariaDB on your server (Update MariaDB Version Linux):
dnf install MariaDB-server
To install the latest version of MariaDB and the most common packages, run the following command:
dnf install MariaDB-server galera-4 MariaDB-client MariaDB-shared MariaDB-backup MariaDB-common
Start and enable your MariaDB service to start on boot:
# systemctl start mariadb
# systemctl enable mariadb
Next, use the following command to upgrade MariaDB on AlmaLinux 9:
mysql_upgrade -u root -p
Output
....
Processing databases
information_schema
performance_schema
sys
sys.sys_config OK
Phase 7/7: Running 'FLUSH PRIVILEGES'
OK
Verify that you have the latest MariaDB on your server by checking its version:
mysql -V
Output
mysql Ver 15.1 Distrib 10.11.3-MariaDB, for Linux (x86_64) using EditLine wrapper
Also, you can check your MariaDB status:
systemctl status mariadb
Output
● mariadb.service - MariaDB 10.11.3 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; preset: >
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: active (running) since Mon 2023-05-15 09:03:46 EDT; 1min 42s ago
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
...
For more information, you can visit the MariaDB Documentation page.
Conclusion
At this point, you have learned to Upgrade MariaDB on AlmaLinux 9 with the simple steps provided in this guide. Hope you enjoy it. You may also interested in these articles: