Skip to content
Follow
Ubuntu Linux

Migrate MySQL to MariaDB on Ubuntu 24.04

Richard
Written by
Richard
Mar 21, 2025 Updated Aug 13, 2026 3 min read
Migrate MySQL to MariaDB on Ubuntu 24.04
Migrate MySQL to MariaDB on Ubuntu 24.04

Migrating MySQL to MariaDB on Ubuntu 24.04 swaps out your database system for a faster, community-driven option. MariaDB acts as a direct drop-in replacement for MySQL, meaning your databases and apps keep working without needing code changes.

Ubuntu 24.04 makes this switch straightforward by letting you swap the software packages safely. Your data stays intact during the process, and you get better performance and more storage engine choices.

⚡ Quick Answer

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

Protect your data by creating a complete backup of all active databases before touching any system files. Saving a copy of the main MySQL configuration file prevents unexpected data loss during the swap.

Refer to the linked guide below for complete database export instructions.

How to backup MySQL databases

Copy the active configuration file to the home directory as a safety net.

🐧Bash / Shell
sudo cp /etc/mysql/my.cnf ~/my.cnf

Database exports finish securely before the next phase begins.

Verify MySQL and MariaDB compatibility

Compatibility checks confirm that the target MariaDB release supports all active database schemas and configurations.

Review the version matrix below before proceeding.

MySQLMariaDB
5.15.1, 5.2, 5.3
5.55.5
5.610.0, 10.1
5.710.2, 10.3, 10.4, 10.5
8.0

Proceed to software removal once version alignment checks pass.

Stop and Uninstall MySQL from Ubuntu

Halt all running database services and strip out the old software packages to keep the environment clean for the new installation.

Execute the command below to terminate active MySQL processes.

🐧Bash / Shell
sudo systemctl stop mysql 

Purge the remaining software packages and associated user accounts from the system.

🐧Bash / Shell
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

System cleanup completes successfully.

Install MariaDB

Official software sources must be added to Ubuntu to fetch the target release.

Navigate to the official repository configuration page.

MariaDB repo config tool

Grab the cryptographic GPG key (a secure digital signature used to verify software authenticity) for the repository, then create a new source file for MariaDB.

🐧Bash / Shell
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'

Write the repository definitions using the terminal editor.

🐧Bash / Shell
sudo nano /etc/apt/sources.list.d/mariadb.sources

Populate the configuration block into the file.

💻Code
# 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 the configuration changes and close the editor.

Refresh package indexes and deploy the database server.

🐧Bash / Shell
sudo apt update
sudo apt install mariadb-server

Restore the previously preserved configuration file to the system path.

🐧Bash / Shell
sudo cp ~/my.cnf /etc/mysql/

Start the database daemons and configure automatic startup routines.

🐧Bash / Shell
sudo systemctl start mariadb

Import the archived database dumps back into the active server environment.

Follow the restoration tutorial below for database import instructions.

Restore the MariaDB database on Ubuntu

Following these procedures establishes a healthy database environment ready for production workloads.

Log into the SQL shell to verify database accessibility.

🐧Bash / Shell
sudo mariadb

Deployment finishes successfully.

Conclusion:

Migrating database platforms on Ubuntu 24.04 yields long-term performance benefits when executed methodically.

  • 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.

System administrators gain a faster, robust database engine backed by active community development.

Was this guide helpful?

Was this helpful?
Richard

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.

📚 Related Tutorials

Backup and Restore MySQL database with mysqldump
Ubuntu Linux Backup and Restore MySQL database with mysqldump
Install MySQL and MariaDB on Ubuntu: A Step-by-Step Guide
Ubuntu Linux Install MySQL and MariaDB on Ubuntu: A Step-by-Step Guide
How to Install GNOME Desktop on Ubuntu 24.04
Ubuntu Linux How to Install GNOME Desktop on Ubuntu 24.04
How to Install KDE Desktop on Ubuntu 24.04
Ubuntu Linux How to Install KDE Desktop on Ubuntu 24.04

No comments yet — be the first to share your thoughts!

Leave a Comment

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