Upgrade from MySQL 5.x to MariaDB 10.x under Debian / Ubuntu at Plesk - this is how it works!
Many admins use the Plesk tool to manage their websites. In this guide we show how the Plesk database is updated from MySQL 5.x to MariaDB 10.x under Debian or Ubuntu.
In our previous guide we have already shown the steps to generally upgrade from MySQL 5.x to MariaDB 10.x without Plesk. In the following the slightly adapted instructions for updating under Plesk.
Replace MySQL 5.x with MariaDB 10.x on Plesk
- Log in to the Plesk server as a root user via SSH.
- Create a backup! The database tables, at best the entire server, should be backed up before the upgrade, as an upgrade can sometimes go wrong. A database dump is performed on a Plesk server as follows:
MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysqldump -u admin – verbose – all-databases – routines – triggers > /root/datenbank-backup.sql
- So that we can start, MySQL must be updated to the latest version (5.7) and Plesk must run on at least version Plesk Obsidian 18.0.30. The Plesk version is updated in the web interface, the packages (like MySQL) with the usual commands:
apt-get update apt-get upgrade
- Check database version - In the best case scenario, MySQL should now run on version 5.7:
- This command should give the following, similar result:
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2187338 Server version: 5.7.35-0ubuntu0.21.04.1 (Ubuntu)
- Add MariaDB repository - auf dieser seite choose the Debian or Ubuntu version used. Then the commands displayed must be carried out. For example the following for a server with Ubuntu 21.04 ("hirsute") and a desired upgrade to MariaDB 10.7:
apt-get install software-properties-common dirmngr apt-transport-https apt-key adv – fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc' add-apt-repository 'deb [arch=amd64,arm64,ppc64el] https://mirror.netcologne.de/mariadb/repo/10.7/ubuntu hirsute main'
- Shut down the MySQL server (on older systems the service may still be called "mysqld"):
service mysql stop
- If the repository and the key from above have been added successfully, the installation of MariaDB will now be carried out. This will remove the old MySQL packages, that's fine.
apt update apt install mariadb-server
- Upgrade the database tables on MariaDB:
MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql_upgrade -uadmin
- Then check that MariaDB has been installed properly. Execute the following command to log into the database:
- This should deliver the following, similar result:
Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 473 Server version: 10.7.1-MariaDB-1:10.7.1+maria~hirsute mariadb.org binary distribution
- In order for Plesk to take over the replaced database in the package manager, two last commands have to be executed:
plesk bin service_node – update local plesk sbin packagemng -sdf
- It is now advisable to check whether all services and websites connected to the database can be reached. Normally, all services compatible with MySQL 5.5-5.7 should work with MariaDB 10 as well. This guarantee is no longer given for future versions of MariaDB.
Upgrade from MySQL 8.x to MariaDB 10.x at Plesk
MariaDB 10.x is a "drop-in" replacement, but only for MySQL versions 5.5 to 5.7. This means that no migration work is necessary afterwards. Future versions of MySQL and MariaDB will differ technically in some points and will no longer be easily replaceable. So if you have already updated to MySQL 8, you have to back up all database tables manually and migrate them to MariaDB. Unfortunately this is the only way, also vice versa (from MariaDB 10.x to MySQL 8.x). There is further support in one Instructions at MariaDB.