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
Locating the Configuration File
sudo find /etc -name "*.cnf" | grep -i maria
On Ubuntu/Debian, MariaDB's main configuration typically lives at /etc/mysql/mariadb.conf.d/50-server.cnf — edit this file for settings like bind-address, memory tuning (see How to Tune MySQL/MariaDB Performance for a VPS), or the data directory location.
Allowing Remote Connections (If Genuinely Needed)
bind-address = 0.0.0.0
By default, MariaDB only accepts connections from localhost — a sensible, secure default. Only change bind-address if you have a genuine need for remote database access, and pair it with firewall rules restricting access to specific known IPs rather than opening it broadly.
Checking Service Status and Logs
sudo systemctl status mariadb
sudo tail -f /var/log/mysql/error.log
Useful for confirming the service started cleanly, and for the first place to check if something behaves unexpectedly after a configuration change.
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.
Continue Reading
- 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
Browse more articles in Databases.