How to upgrade MariaDB in Plesk CentOS 7

CentOS 7 already comes with MariaDB but the version is older. You may need to upgrade it to latest version so that your magento and other scripts can work properly.

First of all create backup of all the databases using below command.

mkdir /mysqlbackup
MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysqldump -u admin –all-databases > /mysqlbackup/all-databases.sql

Now stop the MariaDB

systemctl stop mariadb

Remove the additional mariadb packages if installed

rpm -e mariadb-bench

Create a copy of databae directory in separate folder

cp -ar /var/lib/mysql/ /var/lib/mysql_bakup

Add the mariadb repo

#cat /etc/yum.repos.d/MariaDB10.1.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey = https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck = 1

Perfrom the upgrade

yum install mariadb

Start the mariadb

systemctl start mariadb

Run mysql upgrade

MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql_upgrade -uadmin

Execute this command to update the package version inside Plesk

plesk sbin packagemng -sdf

Remove the init package if installed

rm /etc/init.d/mysql
systemctl daemon-reload

And you are done. Mariadb is now updated to 10.1. You can add mariadb newer version repo if want the latest version.