Skip to content
Follow
Ubuntu Linux

Migrate MySQL to MariaDB on Ubuntu 24.04

Richard
Written by
Richard
Mar 21, 2025 Updated Sep 15, 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 to improve speed and gain extra storage options without breaking your current apps. MariaDB acts as a drop-in replacement for MySQL, meaning your tables and queries keep working normally after the switch.

Advertisement

Ubuntu 24.04 handles the change through its package manager by replacing the old database software while keeping all your existing data safe and intact.

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

Advertisement

Backup current database

Backing up your current database before you migrate MySQL MariaDB keeps your data safe if anything goes wrong during the switch. You need to export all active databases and save a copy of your main configuration file to your home directory before you remove any software from Ubuntu.

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.

Advertisement
🐧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.

Advertisement

Stop and Uninstall MySQL from Ubuntu

Stopping and uninstalling MySQL from Ubuntu removes the old database software so it does not conflict with your new setup. You must halt active background processes and purge the old packages using the terminal before you install MariaDB on your system.

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.

Advertisement

Install MariaDB

Installing MariaDB on Ubuntu 24.04 requires adding the official software repository and cryptographic keys to your system before you pull down the new packages. You need to configure the official source list in your terminal so your package manager downloads the correct version.

Navigate to the official repository configuration page.

MariaDB repo config tool

Download the cryptographic GPG key (a secure digital signature that verifies software authenticity) for the repository, then create a new source file for MariaDB.

Advertisement
🐧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.

Advertisement
🐧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.

Advertisement

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 is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.

Advertisement

📚 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 *