• How to upgrade MySQL 5.5 to 5.6/5.7 or MariaDB 5.5 to 10.0/10.1/10.2 on CentOS 7

This article provides instructions about how to upgrade MySQL 5.5 to 5.6/5.7 or MariaDB 5.5 to 10.0/10.1/10.2 on Linux.

The instructions for upgrading MySQL from 5.1 to 5.5 on Linux see this KB article: https://community.webcore.cloud/tutorials/linux_specific_articles/how_to_upgrade_plesk_mysql_from_51_to_55_on_linux/

Warning: Direct upgrade from MySQL 5.1 to MySQL 5.6/5.7 will damage tables. MariaDB 10.2 is not fully supported by Plesk.

CentOS 7 is shipped with MariaDB. MariaDB 10.x version is a drop-in replacement for MySQL 5.5-5.7.

To automatically upgrade MariaDB use the following script:

Download the attached script and provide it with executable rights:

wget https://plesk.zendesk.com/hc/article_attachments/360022419980/mariadb-10.5-upgrade.sh && chmod +x mariadb-10.5-upgrade.sh

Execute the script via CLI:

./mariadb-10.5-upgrade.sh

Alternative manual upgrade:

Create a backup 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 the MariaDB service:

# service mariadb stop

Remove additional packages like mariadb-bench:

# rpm -e mariadb-bench

Copy a databases directory in a separate folder like this (for backup purposes also):

# cp -a /var/lib/mysql/ /var/lib/mysql_backup

Check if you already have mysql-server installed:

# rpm -q --whatprovides mysql-server

If it is installed and the command above gives output, it is required to be removed using the following command:

# rpm -e --nodeps `rpm -q --whatprovides mysql-server`

Configure MariaDB repository: open the Setting MariaDB repositories page, select OS distro, release and MariaDB version to see the configuration that should be added to /etc/yum.repos.d/MariaDB.repo file. Example for MariaDB 10.1:

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey = https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck = 1

Perform an upgrade with:

# yum install mariadb

Start the MariaDB service:

# service mariadb start

Upgrade MySQL databases:

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

Restart mysql service:

# service mariadb restart

Execute this command to update the package version inside Plesk:

# plesk sbin packagemng -sdf

Note: After an upgrade to 10.1 version, there may appear 'mysql' init script. It can be removed:

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

This article was last modified: May 5, 2021, 11:36 a.m.

0 Comments

Please log in to leave a comment.

Add or change tags.

A comma-separated list of tags.

Share

Hacker News

Top