MariaDB is a community-developed, fully open-source fork of MySQL, offering strong compatibility with MySQL-based applications (WordPress, WHMCS, Joomla) plus additional performance features.
Prerequisites
- Ubuntu 22.04/24.04 or Debian 11/12 VPS
- Root or sudo access
Step 1 — Update the System
sudo apt update
sudo apt upgrade -y
Step 2 — Install MariaDB
sudo apt install mariadb-server mariadb-client -y
Step 3 — Enable and Start MariaDB
sudo systemctl enable mariadb
sudo systemctl start mariadb
sudo systemctl status mariadb
Step 4 — Secure the Installation
sudo mariadb-secure-installation
Set a strong root password, remove anonymous users, disable remote root login, remove the test database, and reload privileges — recommended for every option.
Step 5 — Log In
sudo mariadb
Step 6 — Create a Database and User
CREATE DATABASE myapp;
CREATE USER 'appuser'@'localhost' IDENTIFIED BY 'CHANGE_ME_STRONG_PASSWORD';
GRANT ALL PRIVILEGES ON myapp.* TO 'appuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Verifying the Installation
mariadb --version
Common Errors
MariaDB won't start:
sudo journalctl -u mariadb
Access denied — verify credentials and that FLUSH PRIVILEGES was run after granting access.
Best Practices
- Never use the root account for application connections
- Create a dedicated database and user per application
- Enable regular automated backups
- Keep MariaDB updated with regular system updates
FAQ
Can I migrate directly from MySQL to MariaDB?
Generally yes for standard SQL usage — MariaDB maintains strong wire and data-format compatibility, though it's worth testing application-specific queries before switching a production system.
Related Articles
- How to Install and Secure MySQL 8 on Ubuntu & Debian
- How to Back Up and Restore MySQL/MariaDB Databases
- How to Tune MySQL/MariaDB Performance for a VPS
