Installing MariaDB on Debian/Ubuntu
- Adding MariaDB repository
- Installing MariaDB server
- Checking MariaDB status
- Testing MariaDB connectivity
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.
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:
- for Debian
sudo add-apt-repository "deb [arch=amd64] http://mirror.23media.de/mariadb/repo/10.5/debian $(lsb_release -cs) main"
- for Ubuntu
sudo add-apt-repository "deb [arch=amd64] http://mirror.23media.de/mariadb/repo/10.5/ubuntu $(lsb_release -cs) main"
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
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
If the MariaDB server is not installed, an error will be displayed when checking the status:
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):