How To Upgrade MariaDB on Centos 7

In this guide, we want to teach you How To Upgrade MariaDB on Centos 7. MariaDB is a fast, scalable, and robust database management tool. It supports more storage engines than MySQL. MariaDB also includes many plugins and tools that make it versatile for many use cases.

As you know MariaDB in Centos 7 ships with MariaDB 5 which is not in the latest stable version. You can follow this tutorial to update MariaDB to the latest version on Centos 7.

How To Upgrade MariaDB on Centos 7?

To upgrade your MariaDB service, you need some requirements.

Requirements

First, 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 Centos 7.

Then, you must have a version of MariaDB that is not the latest version.

Now follow the steps below to complete this guide.

Step 1 – Check Current MariaDB Version on Centos 7

The first step is to check the current MariaDB version and Centos version using the below commands:

# mysql -V
Output
mysql Ver 15.1 Distrib 5.5.68-MariaDB, for Linux (x86_64) using readline 5.1
cat /etc/centos-release
Output
CentOS Linux release 7.9.2009 (Core)

Step 2 – Create Backup of Existing 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: During the upgrading process, if you face issues, you can use one of the above copies to restore your databases.

Step 3- Uninstall Old MariaDB Repository on Centos 7

In this step, you need to uninstall the old MariaDB repositories. To do this, stop your MariaDB service on Centos 7 with the following command:
systemctl stop mariadb
Verify that your service is stopped:
systemctl status mariadb
Output
‚óŹ mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Wed 2022-06-22 05:41:22 EDT; 8s ago
Process: 14541 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
Process: 14540 ExecStart=/usr/bin/mysqld_safe --basedir=/usr (code=exited, status=0/SUCCESS)
Process: 14506 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
Main PID: 14540 (code=exited, status=0/SUCCESS)

Move the current MariaDB repository with the following command:

mv /etc/yum.repos.d/mariadb.repo /etc/yum.repos.d/mariadb_bk
Then, run the system with the following command:
yum update

Step 4 – Add New MariaDB Repository on Centos 7

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 the vi editor:
vi /etc/yum.repos.d/MariaDB.repo

Copy and paste the following contents into the file:

Note: At this current time, the latest stable version of MariaDB is version 10.11. You can find the version on the Official Website.

[mariadb]
name = MariaDB
baseurl = https://mariadb.mirror.wearetriple.com/yum/10.11/centos7-amd64
gpgkey=https://mariadb.mirror.wearetriple.com/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1

When you are done, save and close the file.

Now, you need to remove the old MariaDB version by using the command below on Centos 7:

yum remove mariadb-server
Clean the repository cache:
yum clean all

Step 5 – Install Latest MariaDB on Centos 7

At this point, you can install the latest version of MariaDB on your server:
yum install MariaDB-server

To install the latest version of MariaDB and the most common packages, run the following command:

yum 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 your MariaDB on Centos 7:
mysql_upgrade -u root -p
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)

Conclusion

At this point, you have learned to Upgrade MariaDB on Centos 7 step by step. First, you learned to create your backup databases, then removed your old MariaDB repository and added the new MariaDB repo, and install it on your Centos 7. Every time you need to update your MariaDB, you can use this guide.

Hope you enjoy it. You may be interested in these articles:

How To Upgrade PHP Version on Centos 7

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

POPULAR TAGS

Most Popular