Apr 06, 2020 12:40 PM Jun 25, 2020 3:00 AM

Installing MariaDB on Debian/Ubuntu

In this article I will explain how to install a MariaDB server on a Debian/Ubuntu operating system. Your system may not always have the latest packages to install the MariaDB server, or they may not exist at all. MariaDB 10.5 is the latest stable version available for installation.

This instruction was executed on operating systems: Debian 10, Debian 9, Ubuntu 20.10, Ubuntu 20.04, Ubuntu 19.10.

Adding MariaDB repository

If your system does not have packages for installing the MariaDB server, then you need to add an official repository that will provide .deb packages for installing and managing MariaDB. You can also install a newer version of the MariaDB server. But first install the necessary software.

Before any software installation, it is recommended to update the list of repository packages by running the command in the terminal:

sudo apt-get update

Now install the necessary software:

sudo apt-get install lsb-release software-properties-common

Import the repository key to the system:

sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'

Add the MariaDB repository to the list of sources:

Installing MariaDB server

After adding the MariaDB repository, we will update the list of packages by running the command in the terminal:

sudo apt-get update

Install the MariaDB server by running the command in the terminal:

sudo apt-get install mariadb-server

Installing MariaDB server

Checking MariaDB status

Let's check if MariaDB is enabled to start automatically when the system is booted by running the command in the terminal (expected result "enabled"):

sudo systemctl is-enabled mariadb

Let's check if MariaDB is active at the moment by running the command in the terminal (expected result "active"):

sudo systemctl is-active mariadb

We can also check the MariaDB status with additional information about the service by running the command in the terminal:

sudo systemctl status mariadb

–°hecking MariaDB status

If the MariaDB server is not installed, an error will be displayed when checking the status:

Error checking MariaDB status

Testing MariaDB connectivity

Let's check if the root user can connect to the MariaDB server by running the command in the terminal:

sudo mariadb -u root -p

Let's execute a couple of simple queries for testing (getting the current version and displaying the databases):

SELECT VERSION();
SHOW DATABASES;

MariaDB query execution

Other articles