MariaDB is one of the most popular open-source database servers and a drop-in replacement for MySQL. It offers excellent performance, enterprise-grade security, and compatibility with applications such as WordPress, WHMCS, Nextcloud, Joomla, Drupal, and many other web platforms.
Requirements
- Ubuntu 24.04 VPS
- Root or sudo access
- SSH access to your server
Step 1 — Update Your Server
sudo apt update
sudo apt upgrade -y
Step 2 — Install MariaDB Server
sudo apt install mariadb-server mariadb-client -y
Step 3 — Verify Installation
mariadb --version
Example output:
mariadb Ver 11.x.x
Step 4 — Enable MariaDB
sudo systemctl enable mariadb
sudo systemctl start mariadb
Step 5 — Check Service Status
sudo systemctl status mariadb
The service should display active (running).
Step 6 — Secure Your Installation
sudo mariadb-secure-installation
During the setup, it is recommended to:
- Set a strong root password.
- Remove anonymous users.
- Disable remote root login.
- Delete the test database.
- Reload the privilege tables.
Step 7 — Log Into MariaDB
sudo mariadb
Step 8 — Create a Database
CREATE DATABASE mydatabase;
Step 9 — Create a New User
CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'StrongPassword123!';
Step 10 — Grant Permissions
GRANT ALL PRIVILEGES ON mydatabase.* TO 'myuser'@'localhost';
FLUSH PRIVILEGES;
Step 11 — Exit MariaDB
EXIT;
Useful MariaDB Commands
sudo systemctl restart mariadb
sudo systemctl stop mariadb
sudo systemctl status mariadb
mariadb --version
Backup a Database
mariadb-dump -u root -p mydatabase > backup.sql
Restore a Database
mariadb -u root -p mydatabase < backup.sql
Performance Tips
- Enable binary logging if replication is required.
- Increase the InnoDB buffer pool for larger databases.
- Schedule automatic backups.
- Monitor slow queries regularly.
- Keep MariaDB updated to the latest stable release.
Best Practices
- Never use the root account for applications.
- Create separate users for each website.
- Use strong passwords and least-privilege permissions.
- Restrict remote database access using a firewall.
- Monitor logs for suspicious activity.
Conclusion
MariaDB is a fast, secure, and highly compatible database server that is ideal for modern VPS hosting. Whether you're running WordPress, WHMCS, Laravel, or custom applications, MariaDB delivers excellent performance while remaining easy to manage.
Related Articles
- How to Install MySQL 8 on Ubuntu 24.04 VPS
- How to Install PostgreSQL 17 on Ubuntu 24.04 VPS
- How to Install PHP 8.4 on Ubuntu 24.04 VPS
- How to Install Nginx on Ubuntu 24.04 VPS
- How to Secure Your Linux VPS
