Install on Ubuntu and Debian
sudo apt update
sudo apt install mariadb-serverThis installs the MariaDB server and the mariadb client from the distribution's own repositories. The service starts by itself and is enabled at boot. On Debian, MariaDB is the default MySQL-compatible server; Debian 12 and 13 have no mysql-server package. On Ubuntu both are available, but the two server packages conflict, so install one of them, not both. For MySQL instead, see how to install MySQL on Ubuntu.
Install on AlmaLinux and Rocky Linux
sudo dnf install mariadb-server
sudo systemctl enable --now mariadbOn the RHEL family the service is not started after installation, so the second command starts it and enables it at boot. To see which version the repositories offer before you install, run dnf info mariadb-server. The AppStream repository also carries MySQL (mysql-server on version 9, mysql8.4-server on version 10); choose one of the two.
Check the Service and the Version
sudo systemctl status mariadb
mariadb --version
sudo mariadb -e "SELECT VERSION();"The first command should show the service as active. The second shows the client version and the third the running server, whose version string contains the word MariaDB. More ways to read it are in how to check the MySQL version. If the service is not active, read its messages with sudo journalctl -u mariadb.
Run the Security Script
sudo mariadb-secure-installationThe script's older name is mysql_; on Debian 13 and Ubuntu 26.04 that old name comes only with the mariadb-client-compat package. It asks a series of questions:
- Current root password: press Enter. Root has no password; it logs in through the socket.
- Switch to unix_
socket authentication: if the script reports that root is already protected this way, answer no; nothing changes. - Change the root password: answer no and keep socket login.
- Remove anonymous users: yes.
- Disallow root login remotely: yes.
- Remove the test database: yes.
- Reload privilege tables: yes, so the changes apply at once.
How root Logs In
sudo mariadbNo password is asked. MariaDB's root account uses the unix_ plugin by default: the server checks that the Linux user running the client is root. Only users with sudo rights get in, which is safer than a password that can be guessed. To see how the account is defined:
SHOW CREATE USER 'root'@'localhost';Use root for administration only. Applications get their own accounts.
Create a Database and an Application User
Inside sudo mariadb:
CREATE DATABASE app CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'app_user'@'localhost' IDENTIFIED BY 'STRONG_PASSWORD';
GRANT ALL PRIVILEGES ON app.* TO 'app_user'@'localhost';Replace STRONG_ with a long random password. The details are in how to create a database in MySQL and how to create a MySQL user; both apply to MariaDB unchanged.
Keep MariaDB Local
On Debian and Ubuntu, the server configuration is /etc/mysql/mariadb.conf.d/50-server.cnf, and it sets bind-address = 127.0.0.1. On AlmaLinux and Rocky Linux the server options live in /etc/my.cnf.d/, and the packaged files there do not necessarily set an address. Check what the server listens on:
sudo ss -tlnp | grep mariadbdIf port 3306 shows an address other than 127.0.0.1 and your application runs on the same server, add bind-address = 127.0.0.1 under [mysqld] and restart the service. Keep port 3306 closed in the firewall either way. If another server really must connect, follow how to allow remote connections to MySQL.
Service Commands
| Task | Command |
|---|---|
| Restart | sudo systemctl restart mariadb |
| Stop | sudo systemctl stop mariadb |
| Start at boot | sudo systemctl enable mariadb |
The main tools also answer to the old names: mysql, mysqldump, and mysqladmin work alongside mariadb, mariadb-dump, and mariadb-admin. On Debian 13 and Ubuntu 26.04, other old names such as mysqlshow need the compatibility package. Schedule a dump of each database before you put data on the server.
Updated:
Linux VPS with Full Root Access
MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.
More Guides
No Limits on Service or Support
You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

- 100% customer satisfaction goal
- Our own hardware
- 24/7 ticket and email support
- 4 countries with locations