Migrate MySQL to MariaDB on Ubuntu 24.04
Migrating MySQL to MariaDB on Ubuntu 24.04 switches your database to a free, community-driven system with extra features.
MariaDB is a database that works very much like MySQL. It’s built from MySQL’s code, so it’s compatible but often runs faster and has more options.
This switch is common because MariaDB offers a strong, open-source option that can be better than MySQL. It even includes advanced features like Percona XtraDB Cluster.
You can move your existing data to MariaDB safely and quickly. This guide helps you do it with minimal interruption to your systems.
Stop and uninstall MySQL using `systemctl stop mysql`, `apt-get remove`, and `deluser mysql`. Install MariaDB from its official repository using `apt install mariadb-server`. Restore your backed-up databases to complete the migration.
Backup current database
Before migrating MySQL to MariaDB, you must back up your current databases. Backing up your current databases creates a safety copy of all your information. Backing up your main MySQL settings file adds extra safety and helps prevent data loss if problems happen during the MariaDB migration.
If you’re new to backing up MySQL databases, the linked post below will guide you through the process.
sudo cp /etc/mysql/my.cnf ~/my.cnf
With your MySQL databases backed up, you can continue to the next step.
Verify MySQL and MariaDB compatibility
Before migrating from MySQL to MariaDB on Ubuntu 24.04, it’s essential to check compatibility. This step confirms that the MariaDB version you’re upgrading to supports all your current MySQL features and data, helping to prevent issues during the migration.
Below is a table that illustrates the compatibility between different versions of MySQL and MariaDB.
| MySQL | MariaDB |
| 5.1 | 5.1, 5.2, 5.3 |
| 5.5 | 5.5 |
| 5.6 | 10.0, 10.1 |
| 5.7 | 10.2, 10.3, 10.4, 10.5 |
| 8.0 | – |
Continue below if everything is good.
Stop and Uninstall MySQL from Ubuntu
To migrate MySQL to MariaDB without issues, you must first stop and uninstall MySQL from Ubuntu 24.04. This action stops any running MySQL services and removes all related software and accounts. Stopping and uninstalling MySQL ensures your system is clean and ready for the new MariaDB database installation.
Run the command below to stop MySQL services.
sudo systemctl stop mysql
Next, remove MySQL stuff and the user from Ubuntu by running the command below.
sudo apt-get remove mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
sudo deluser mysql
sudo rm -rf /var/lib/mysql
MySQL should be uninstalled.
Install MariaDB
After you uninstall MySQL, the next step to migrate MySQL to MariaDB is to install MariaDB on Ubuntu. The latest version is available from the MariaDB repository config tool website. Follow the instructions there to add the correct software sources before installing MariaDB.
To install the latest version, head to the MariaDB repository config tool site linked below.
Choose the correct version and repository for MariaDB version 10 on Ubuntu. Use the provided GPG key for the repository.
sudo apt install apt-transport-https curl
sudo mkdir -p /etc/apt/keyrings
sudo curl -o /etc/apt/keyrings/mariadb-keyring.pgp 'https://mariadb.org/mariadb_release_signing_key.pgp'
Then, create a repository file for MariaDB using the command below.
sudo nano /etc/apt/sources.list.d/mariadb.sources
Copy the content provided into the file, then save and exit.
# MariaDB 10.11 repository list - created 2025-03-21 17:45 UTC
# https://mariadb.org/download/
X-Repolib-Name: MariaDB
Types: deb
# deb.mariadb.org is a dynamic mirror if your preferred mirror goes offline. See https://mariadb.org/mirrorbits/ for details.
# URIs: https://deb.mariadb.org/10.11/ubuntu
URIs: https://mirrors.accretive-networks.net/mariadb/repo/10.11/ubuntu
Suites: noble
Components: main main/debug
Signed-By: /etc/apt/keyrings/mariadb-keyring.pgp
Save and exit.
Finally, run the command below to update the Ubuntu package index and install MariaDB 10.
sudo apt update
sudo apt install mariadb-server
After installing the MariaDB server, restore the main configuration file backed up above.
sudo cp ~/my.cnf /etc/mysql/
Then, start and enable its services.
sudo systemctl start mariadb
Finally, restore the databases backed up previously to the new MariaDB server.
Learn how to restore MariaDB using the post below.
Restore the MariaDB database on Ubuntu
By following these steps, you’ll have a smooth transition to MariaDB and can start enjoying all its extra features and improvements.
To sign on to the MariaDB server, run the command below.
sudo mariadb
That should do it!
Conclusion:
Migrating from MySQL to MariaDB on Ubuntu 24.04 offers a process when you follow specific steps. Key advantages of MariaDB include its open-source nature and faster performance, making it a popular alternative for database needs.
- Backup Important Data: Always ensure you have a complete backup of your databases and configuration files before starting the migration.
- Compatibility Check: Verify the compatibility between your MySQL version and the MariaDB version to avoid potential issues.
- Uninstall MySQL: Completely remove MySQL from your system to prepare for the installation of MariaDB.
- Install MariaDB: Use the official repository to install the most recent version of MariaDB on your Ubuntu system.
- Restore Backups: After installation, restore your databases to the new MariaDB server to regain access to your data.
- Test Functionality: Once migrated, log into MariaDB and perform checks to ensure everything functions correctly.
By following these steps, you’ll have a smooth transition to MariaDB and can start enjoying all its extra features and improvements.
Was this guide helpful?
About the Author
Richard
Tech Writer, IT Professional
Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.
No comments yet — be the first to share your thoughts!