Upgrade from MySQL 5.x to MariaDB 10.x under Debian / Ubuntu - this is how it works!
The open source world of MySQL is currently switching more and more to MariaDB. Some users are now faced with the question of how the switch is possible. In this guide we show how a MySQL 5 database can be easily exchanged for MariaDB 10.
A little background: After Oracle announced controversial license changes with MySQL 8, more and more supporters of open source software are withdrawing from the database hirschen. Future versions of MySQL are to be developed “closed” - exactly the opposite of open source. For this reason, for example, the popular Linux distributions Debian and Ubuntu in their current versions also include MariaDB as standard instead of MySQL.
Is the Plesk administration tool running on the server? Then the steps for the upgrade are a little different. Then please work through the following guide:
It's that easy to upgrade from MySQL 5.x to MariaDB 10.x.
- 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.
- So that we can start, MySQL has to be updated to the latest version (5.7), but at least to 5.5. This happens with the usual commands:
sudo apt-get update sudo apt-get upgrade
- Check database version - In the best case scenario, MySQL should now run on version 5.7:
mysql
- 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:
sudo apt-get install software-properties-common dirmngr apt-transport-https sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc' sudo 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"):
sudo 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.
sudo apt update sudo apt install mariadb-server
- Upgrade the database tables on MariaDB:
mysql_upgrade
- Then check that MariaDB has been installed properly. Run the following command:
mysql
- 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
- 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
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.