This article provides instructions for upgrading MariaDB 5.5 to 10.0/10.1/10.2 on Linux.
By default, CentOS 7 is shipped with MariaDB 5.5. MariaDB 10.x version is a drop-in replacement for MySQL 5.5-5.7.
-
For security reasons, create a database dump of all databases with the following command:
# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysqldump -u admin --all-databases --routines --triggers > /tmp/all-databases.sql
-
Stop MariaDB:
# service mariadb stop
-
Remove additional packages like mariadb-bench:
# rpm -e --nodeps mariadb-bench
-
For security reasons, copy the database directory in a separate folder:
# cp -a /var/lib/mysql/ /var/lib/mysql_backup
-
Check if the mysql-server package is already installed:
# rpm -q --whatprovides mysql-server
If it is installed and the command above gives output, remove using the following command:
# rpm -e --nodeps `rpm -q --whatprovides mysql-server`
-
Configure MariaDB repository: open the Setting MariaDB repositories page, select your OS distro, release and a desired MariaDB version. Once done, the configuration that should be added to the /etc/yum.repos.d/MariaDB.repo file will appear.
Here is an example for MariaDB 10.2:
6.1. Open/create the MariaDB.repo file in any text editor. In this example, we are using the vi editor:
# vi /etc/yum.repos.d/MariaDB.repo
6.2. Add the content below to the file:
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=16.3. Save the changes and close the file.
-
Start an upgrade of MariaDB:
# yum install MariaDB-client MariaDB-server
-
Once the upgrade is finished, start MariaDB:
# service mariadb start
OR
# service mysql start
-
Upgrade MySQL databases:
# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql_upgrade -uadmin
-
Restart mysql service:
# service mariadb restart
OR
# service mysql restart
-
Execute this command to update the package version inside Plesk:
# plesk sbin packagemng -sdf
Note: After an upgrade to 10.2 version, there may appear 'mysql' init script. It can be removed.
# rm /etc/init.d/mysql
# systemctl daemon-reload