...
Skip to main content
Print

How to Install MariaDB on Ubuntu

You install MariaDB on Ubuntu with apt install mariadb-server. Then secure the installation with mariadb-secure-installation and create a separate database and user for each website. MariaDB is a fast, fully compatible replacement for MySQL. You use it for WordPress, web shops and your own applications, among other things.

Step 1: install MariaDB

apt update
apt install mariadb-server -y
systemctl enable --now mariadb

Step 2: secure the installation

mariadb-secure-installation

Answer the questions with Y: remove anonymous users, disallow remote root login and remove the test database.

Step 3: create a database and user

Open the MariaDB console:

mariadb

Create the database and user. Choose a strong password:

CREATE DATABASE mijnsite;
CREATE USER 'mijnsite'@'localhost' IDENTIFIED BY 'STERK-WACHTWOORD';
GRANT ALL PRIVILEGES ON mijnsite.* TO 'mijnsite'@'localhost';
FLUSH PRIVILEGES;
EXIT;

MariaDB on AlmaLinux

dnf install mariadb-server -y
systemctl enable --now mariadb
mariadb-secure-installation

Making a backup of your database

With mariadb-dump you put a database into a single file:

mariadb-dump mijnsite > mijnsite.sql

Schedule this automatically with a cron job.

Related articles

Table of Contents