Here are the steps to install MariaDB on Debian 12:

  1. Update your Debian 12 to the latest version.
  2. Install MariaDB.
  3. Configure the database man­age­ment system.
  4. Check the status of the server and access the database.

MariaDB is in the Debian 12 repos­i­to­ry by default

When looking at the MySQL vs. MariaDB com­par­i­son, it’s easy to see that the fork (MariaDB) is a very robust, secure and flexible al­ter­na­tive. It is no co­in­ci­dence that it is part of the standard reper­toire in Debian. As a drop-in re­place­ment for MySQL, the SQL server can be in­te­grat­ed into the LAMP stack (Linux, Apache, MySQL and PHP, Python or Perl) without any major changes. Nev­er­the­less, there are still a few points that you should be aware of when it comes to security when in­stalling MariaDB on Debian 12. We will guide you through the in­stal­la­tion step by step here.

Tip

If the plan is to install MariaDB on Debian 10, you will find all the necessary steps in the Digital Guide. We have also sum­ma­rized every­thing you need to know about in­stalling MariaDB on Debian 11 in detail. If you would like to use MongoDB on Debian 10 instead, we also have an article on the topic.

What re­quire­ments must be met?

There are only a few re­quire­ments that your system must fulfill when in­stalling MariaDB on Debian 12. It is important that Debian 12 is already installed and that you have suf­fi­cient memory. The minimum re­quire­ments are 512 megabytes of RAM and 1 gigabyte of hard disk space. One CPU core is suf­fi­cient for a server in normal operation. In addition, you need root access and an active firewall.

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

How to install MariaDB on Debian 12

In the following sections we will explain how to install MariaDB on a Debian 12 device in detail.

Step 1: Update system and packages to the latest version

Before you install MariaDB on Debian 12, it makes sense to update the system so you have the latest version. Among other things, this will help you avoid security problems and benefit from bug fixes and the most current updates. To update the package index and all de­pen­den­cies, use these two apt commands:

sudo apt update
sudo apt upgrade
bash

All system packages are now up to date, and you can continue with the in­stal­la­tion.

Step 2: Version control and in­stal­la­tion of MariaDB on Debian 12

After the update is complete, you can begin with the in­stal­la­tion of MariaDB on Debian 12. The current version of the SQL server is normally contained in the Debian 12 repos­i­to­ry. You can use the following command to check this:

sudo apt show mariadb-server
bash

This shows you which version is included. If the desired version is included, execute the following command to start the in­stal­la­tion:

sudo apt install mariadb-server
bash

You will be asked for your password during the process. The process will continue once you’ve entered it.

Step 3: Secure and configure MariaDB after in­stal­la­tion

You should then ad­di­tion­al­ly secure MariaDB. The program provides its own security script for this purpose, which you can use to set in­di­vid­ual security mech­a­nisms. You execute it with the following command:

sudo mysql_secure_installation
bash

This script offers you some ad­di­tion­al options to secure or strength­en the in­stal­la­tion. For example, you can set up a root password, remove anonymous users, delete the test database and prevent remote root logins. To perform actions, enter [Y]. If you do not want to take any action, select [N]. Confirm both options with [Enter].

Step 4: Check the in­stal­la­tion and version

After in­stalling MariaDB on Debian 12 is finished, the program will start au­to­mat­i­cal­ly. To check the status of MariaDB, enter the following command:

sudo systemctl status mariadb
bash

If you want to start MariaDB, use this command:

sudo mariadb
bash

This command enables you to check which version number of MariaDB is being used:

> SELECT version();
sql

To uninstall MariaDB on Debian 12, simply use the following command:

sudo apt purge mariadb-server
bash

As a last step, press [Y] and [Enter] to confirm that you really want to delete the server com­plete­ly. MariaDB will then be removed from your system.

Go to Main Menu