MariaDB is a free, relational, open-source database management system created through a fork from MySQL. You can read our guide MySQL Vs MariaDB for WordPress for comparison. The project was initiated by MySQL’s former lead developer, Michael Widenius, who also developed the Aria storage engine on which MariaDB was originally built (the software layer that contains the basic functionality of the database, i.e. creating, reading, modifying, deleting data). Since Oracle holds the trademark rights to MySQL, new names had to be found for the database system and its storage engines. The name MariaDB goes back to Widenius’ younger daughter Maria, just as MySQL did to his older daughter My.
Steps to Perform Before Installing MariaDB on Ubuntu 22.04
You can use VPSDime OpenVZ instances for small to medium websites. 6GB RAM, 10Gbps connection instances will cost you $7.00/mo. We have an article on OpenVZ Vs Docker for better understanding. If you need dedicated resources, then you can test their premium KVM VPS. You can request them to install MariaDB and PHPMyAdmin or cPanel (if you are hosting multiple websites) for a small fee. The links we have provided you are affiliate links. VPSDime is intended for the developers and they are supportive.
Your first work after getting the server in “hand” is to follow this guide How To Set up a Passwordless SSH Login in Ubuntu 22.04. You can install Fail2Ban on Ubuntu 22.04 later.
---
You must not be the root user while installing MariaDB. It will confuse you between the root users of MariaDB and also allow the hackers to easily get access.

How To Install MariaDB on Ubuntu 22.04
Run these commands:
1 2 3 4 | sudo apt update -y sudo apt upgrade -y sudo apt install mariadb-server sudo mysql_secure_installation |
Except for adding a new password, removing the test databases and reloading privileges, you need not change anything. Never change anything related to this root user account. On Debian-based systems, it is risky to disturb it. If you change the password of this root account later, you may face odd errors. Do not use the root user with a password in WordPress configuration files such as wp-config.php.
Create a new user with the privileges same as the root user with the name admin:
1 2 3 4 | sudo mariadb GRANT ALL ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION; FLUSH PRIVILEGES; exit; |
Now, log in as admin to MariaDB:
1 | sudo mysql -u admin -p |
Create a database for WordPress using the following command. We have named it wordpress and the user as wpuser, but you can use whatever name you like:
1 2 3 4 5 | create database wordpress; create user wpuser@localhost identified by 'your-password'; grant all privileges on wordpress.* to wpuser@localhost; flush privileges; exit; |
Check the database and user:
1 2 3 | sudo mysql -u wpuser -p show databases; exit; |
This ends the steps required to install WordPress. However, we need to tweak the MariaDB settings file for optimal performance.
I have an optimized mariadb.cnf file on GitHub for your work. This is intended for a 12GB server.
After altering the file (just replace the content of /etc/mysql/mariadb.cnf) and restarting MySQL (service mysql restart), you can use MySQL Tuner for further optimization.