In order to install MariaDB on Debian 11, the following steps are required:

  1. Update your Debian 11 in­stall­a­tion.
  2. Install MariaDB.
  3. Customise the con­fig­ur­a­tion according to your re­quire­ments.
  4. Create an ad­di­tion­al admin user (optional).
  5. Check whether the in­stall­a­tion was suc­cess­ful.

Why are MariaDB and Debian 11 a good fit?

In the MariaDB v. MySQL com­par­is­on, MariaDB has long since proven itself. This SQL server is known for being extremely robust, highly secure, and generally more flexible than the older database man­age­ment system of the same origin. Designed as a direct drop-in re­place­ment for MySQL, it can be used as a MySQL sub­sti­tute within the LAMP stack (Linux, Apache, MySQL, and PHP, Python, or Perl) without sig­ni­fic­ant ad­just­ments being required. Debian has also been using MariaDB for quite some time and contains the necessary packages by default.

Tip

If you want to install MariaDB on Debian 10, you will find helpful in­struc­tions in our Digital Guide as well as some for setting up MariaDB on Debian 12. If you want to use MongoDB on Debian 10 instead, we will also guide you through all the necessary steps.

What re­quire­ments must be met?

There are only a few re­quire­ments that need to be met to install MariaDB in­stall­a­tion on Debian 11. The first is that you need a server that Debian 11 is already installed on. Root access for this server is required and a suitable firewall should be set up and activated. As a rule, one CPU core is suf­fi­cient. In addition, at least 512 megabytes of RAM and 1 gigabyte of hard disk space are required.

Compute Engine
The ideal IaaS for your workload
  • Cost-effective vCPUs and powerful dedicated cores
  • Flex­ib­il­ity with no minimum contract
  • 24/7 expert support included

How to install MariaDB on Debian 11 step by step

The following sections show you step by step how to install MariaDB on Debian 11.

Step 1: Update the package index

Before you start the actual in­stall­a­tion, you should make sure that all your programs and Debian 11 itself are up to date. To do this, update the package index with these two apt commands:

sudo apt update
sudo apt upgrade
bash

Once this is done, you can start in­stalling MariaDB on Debian 11.

Step 2: Install MariaDB on Debian 11

Use the following command to install the package for MariaDB:

sudo apt install mariadb-server
bash

Once this process is complete, it means you have installed MariaDB on Debian 11, but no security pre­cau­tions have yet been taken for your system. This part comes in the next step.

Step 3: Execute the security script

MariaDB offers its own security script for its newer versions. You can use this script to modify some default settings. The command to initiate the script is as follows:

sudo mysql_secure_installation
bash

When you start the script, you’ll first be prompted to enter your root password for the database. Since you haven’t set this up yet, press [Enter] to skip this step for now. Then, you will be asked if you want to switch to au­then­tic­a­tion via unix_socket. Type [N] and press [Enter] to confirm.

You will be asked if you want to change your root password. However, this is not re­com­men­ded for security reasons, so press [N] and [Enter] again. Answer the following questions with [Y] to remove anonymous users, the test database and root logins remotely.

Step 4: Set up an ad­di­tion­al admin (optional)

The next step is optional but highly re­com­men­ded for securing your system. In Debian 11, the MariaDB root user is au­then­tic­ated using unix_socket instead of a password. Although this has some benefits, it can cause problems when external programs need admin rights. A solution is to create an ad­di­tion­al admin user to com­ple­ment the root account. Here are the steps to do this:

Open the MariaDB shell:

sudo mariadb -u root
bash

Now create the new user. Change the username and password as required.

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' WITH GRANT OPTION;
sql

Use the ‘FLUSH PRIV­ILEGES’ command for security:

FLUSH PRIVILEGES;
sql

Finally, close the shell:

exit
bash

Step 5: Check whether the in­stall­a­tion was suc­cess­ful

Finally, check whether the in­stall­a­tion of MariaDB on Debian 11 was a success. To do this, test the status with this command:

sudo systemctl status mariadb
bash

If MariaDB does not start auto­mat­ic­ally, use the following command:

sudo systemctl start mariadb
bash

You’re now free to use MariaDB.

Go to Main Menu