Share your love
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
cp -a /var/lib/mysql /var/lib/mysql.backup
cp -a /etc/my.cnf /etc/my.cnf_bk
Step 3- Uninstall Old MariaDB Repository on Centos 7
systemctl stop mariadb
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
yum update
Step 4 – Add New MariaDB Repository on Centos 7
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
yum clean all
Step 5 – Install Latest MariaDB on Centos 7
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
systemctl start mariadb
systemctl enable mariadb
mysql_upgrade -u root -p
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: