MariaDB migration to MySQL

mariadbIn my last post I’ve explained how and why we need MySQL instead of the default MariaDB from the Debian repo. In the post, I’ve stated that I’ve assumed that there isn’t already a MariaDB installation active. But what when there is?

Then we have to migrate from MariaDB to MySQL. It looks simple, but it really can be a tedious job. Hence a short walkthrough how to do this properly.

When necessary, export your existing databases.

# mysqldump --all-databases > mydump.sql

In my experience it is more reliable to export the databases into separate files and in your new setup create a new user and give appropriate privileges. Export a single database like this:

# mysqldump --single-transaction databasename > databasename.sql

Remove the software:

# apt remove mariadb-client mariadb-server
# apt purge mariadb-client mariadb-server
# apt autoremove

Remove the user and the homefolder manually:

# userdel -rf mysql
# rm -rf /var/lib/mysql

Install the software like in the previous post:

# cd /tmp
# wget
# dpkg -i mysql-apt-config_0.8.11-1_all.deb
# apt update
# apt install mysql-community-client mysql-community-server

Now it is still possible you’ll receive an error:

dpkg: error while cleaning up:

If so, remove the software again with some additional configuration:

# apt --fix-broken install
# apt remove mysql-community-client mysql-community-server
# apt purge mysql-community-client mysql-community-server
# apt autoremove

Remove the MariaDB logrotate:

# cd /etc/logrotate.d/
# rm mysql-server

Now it should be fine. Install and check the software:

# apt install mysql-community-client mysql-community-server
# systemctl status mysql

Import your databases and configure users and privileges (when you’ve used the –single-transaction option).

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.