How to Install MariaDB 10.6 on Debian 11

MariaDB is one of the most popular open-source databases next to its originator MySQL. The original creators of MySQL developed MariaDB in response to fears that MySQL will suddenly become a paid service due to Oracle acquiring it in 2010. With its history of doing similar tactics, the developers behind MariaDB have promised to keep it open source and free from such fears as what has happened to MySQL.

MariaDB has become just as popular as MySQL with developers, with features such as advanced clustering with Galera Cluster 4, faster cache/indexes, storage engines, and features/extensions that you won’t find in MySQL.

In the following tutorial, you will learn how to install MariaDB 10.6 on Debian 11.


Updating Operating System

Update your Debian 11 operating system to make sure all existing packages are up to date:

sudo apt update && sudo apt upgrade

Install Depedencies

The first step is to install the dependencies needed for the installation. To do this, use the following command in your terminal:

sudo apt-get install curl software-properties-common dirmngr -y

Import GPG Key & Repository

To successfully install MariaDB, you will need to import the GPG key to verify that the packages are from the authentic source and not modified. To do this, use the following command:

sudo curl -LsSO
sudo chmod -c 644 mariadb_release_signing_key.asc
sudo mv -vi mariadb_release_signing_key.asc /etc/apt/trusted.gpg.d/
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] bullseye main'

Note, download mirrors can be found on this page from MariaDB foundation to find a location closer to you for the repository.

Example output:

Now that the key and repository are imported update the apt package manager list to reflect the new addition.

sudo apt update

Install MariaDB

To install MariaDB, you will need to install the client and the server packages. This can be done as follows:

sudo apt install mariadb-server mariadb-client

Example output:

How to Install MariaDB 10.6 on Debian 11

Type Y and then press the enter key to proceed with the installation.

Confirm the installation of MariaDB by checking the version and build:

mariadb --version

Example output:

mariadb  Ver 15.1 Distrib 10.6.4-MariaDB, for debian-linux-gnu (x86_64) using readline EditLine wrapper

Check MariaDB server status

Now you have installed MariaDB, and you can verify the status of the database software by using the following systemctl command:

systemctl status mariadb

By default, you will find MariaDB status to be off. To start MariaDB, use the following command:

sudo systemctl start mariadb

Now recheck the status, and you should get the following:

How to Install MariaDB 10.6 on Debian 11

To stop MariaDB:

sudo systemctl stop mariadb

To enable MariaDB on system startup:

sudo systemctl enable mariadb

To disable MariaDB on system startup:

sudo systemctl disable mariadb

To restart the MariaDB service:

sudo systemctl restart mariadb

Secure MariaDB with Security Script

When installing MariaDB fresh, the default settings that default are considered weak by most standards and cause concern for potentially allowing intrusion or exploiting hackers, a solution is to run the installation security script that comes with the MariaDB installation.

First, use the following command to launch the (mysql_secure_installation):

sudo mysql_secure_installation

Next, follow below:

  • Setting the password for root accounts.
  • Removing root accounts that are accessible from outside the local host.
  • Removing anonymous-user accounts.
  • Removing the test database, which by default can be accessed by anonymous users.

Note, you use (Y) to remove everything.

Login to MariaDB instance

Now that you have completed the post-installation installation security script, login into your MariaDB database can be done using the following:

sudo mysql -u root -p

You will be prompted to enter your root password, and then you will be successfully logged into the MariaDB database terminal:


How to Install MariaDB 10.6 on Debian 11

To exit the terminal, type the following exit command:


Uninstall MariaDB

If you no longer wish to use MariaDB and want to remove it in full, execute the following command:

sudo apt autoremove maridb-server mariadb-client

Remove the GPG key:

sudo rm /etc/apt/trusted.gpg.d/mariadb_release_signing_key.asc

Remove the Repo:

sudo rm /etc/apt/sources.list.d/mariadb.list

Comments and Conclusion

In the tutorial, you have learned how to install the latest version of MariaDB on the latest stable release Debian 11. Overall, it would help if you upgraded from the old stable 10.5 as it’s quite seasoned now compared to 10.6, and there are huge advantages in performance with upgrading. If you do upgrade, make sure to always back up your database before doing so to avoid countless hours of pain and utter frustration.


Like to get automatic updates? Follow us on one of our social media accounts!