Skip to main content

Install MariaDB

This guide explains how to install MariaDB on your Linux VPS.

Installation​

Debian / Ubuntu​

sudo apt update
sudo apt install mariadb-server mariadb-client -y

CentOS / AlmaLinux​

sudo dnf install mariadb-server mariadb -y
sudo systemctl start mariadb
sudo systemctl enable mariadb

Security​

Run the security script:

sudo mysql_secure_installation

Answer the questions:

  • Enter current password for root: Press Enter
  • Set root password?: Y, then enter a password
  • Remove anonymous users?: Y
  • Disallow root login remotely?: Y
  • Remove test database?: Y
  • Reload privilege tables?: Y

Create a database​

sudo mysql -u root -p
CREATE DATABASE my_database;
CREATE USER 'my_user'@'localhost' IDENTIFIED BY 'my_password';
GRANT ALL PRIVILEGES ON my_database.* TO 'my_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Useful commands​

CommandDescription
sudo systemctl status mariadbCheck status
sudo systemctl restart mariadbRestart
sudo systemctl stop mariadbStop