Knowledge Base

HomepageKnowledge BaseHow to Replace MySQL with MariaDB on Ubuntu VP...

How to Replace MySQL with MariaDB on Ubuntu VPS

Step 1 — Backup Your MySQL Databases

bash

sudo mysqldump --all-databases --single-transaction --quick --lock-tables=false > backup.sql

Step 2 — Stop MySQL Service

bash

sudo systemctl stop mysql

Step 3 — Remove MySQL Server (Safe Removal)

This removes MySQL binaries but keeps your data directory.

bash

sudo apt remove --purge mysql-server mysql-client mysql-common -y

sudo apt autoremove -y

sudo apt autoclean

Check if MySQL directories still exist:

bash

 

ls /var/lib/mysql

(They should remain — MariaDB will reuse them.)

Step 4 — Install MariaDB Server

Ubuntu repository:

bash

 

sudo apt update

sudo apt install mariadb-server mariadb-client -y

Start and enable MariaDB:

bash

sudo systemctl start mariadb

sudo systemctl enable mariadb

Step 5 — Secure MariaDB Installation

bash

sudo mysql_secure_installation

Follow prompts to set root password, remove test DB, etc.

 

Step 6 — Verify MariaDB is Running

bash

 

mysql -V

 

You should see something like:

Code

mysql  Ver 15.1 Distrib 10.11.6-MariaDB

Login:

bash

sudo mysql

Step 7 — (Optional) Restore Backup

If needed:

bash

mysql < backup.sql

 

 

 

Can't find the information you are looking for?

Create a Support Ticket
Did you find it useful?
(18 times viewed / 0 people found it helpful)

Top