How to install MariaDB on Debian 12
Here are the steps to install MariaDB on Debian 12:
- Update your Debian 12 to the latest version.
- Install MariaDB.
- Configure the database management system.
- Check the status of the server and access the database.
MariaDB is in the Debian 12 repository by default
When looking at the MySQL vs. MariaDB comparison, it’s easy to see that the fork (MariaDB) is a very robust, secure and flexible alternative. It is no coincidence that it is part of the standard repertoire in Debian. As a drop-in replacement for MySQL, the SQL server can be integrated into the LAMP stack (Linux, Apache, MySQL and PHP, Python or Perl) without any major changes. Nevertheless, there are still a few points that you should be aware of when it comes to security when installing MariaDB on Debian 12. We will guide you through the installation step by step here.
If the plan is to install MariaDB on Debian 10, you will find all the necessary steps in the Digital Guide. We have also summarized everything you need to know about installing 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 requirements must be met?
There are only a few requirements that your system must fulfill when installing MariaDB on Debian 12. It is important that Debian 12 is already installed and that you have sufficient memory. The minimum requirements are 512 megabytes of RAM and 1 gigabyte of hard disk space. One CPU core is sufficient for a server in normal operation. In addition, you need root access and an active firewall.
- Cost-effective vCPUs and powerful dedicated cores
- Flexibility 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 dependencies, use these two apt
commands:
sudo apt update
sudo apt upgrade
bashAll system packages are now up to date, and you can continue with the installation.
Step 2: Version control and installation of MariaDB on Debian 12
After the update is complete, you can begin with the installation of MariaDB on Debian 12. The current version of the SQL server is normally contained in the Debian 12 repository. You can use the following command to check this:
sudo apt show mariadb-server
bashThis shows you which version is included. If the desired version is included, execute the following command to start the installation:
sudo apt install mariadb-server
bashYou 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 installation
You should then additionally secure MariaDB. The program provides its own security script for this purpose, which you can use to set individual security mechanisms. You execute it with the following command:
sudo mysql_secure_installation
bashThis script offers you some additional options to secure or strengthen the installation. 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 installation and version
After installing MariaDB on Debian 12 is finished, the program will start automatically. To check the status of MariaDB, enter the following command:
sudo systemctl status mariadb
bashIf you want to start MariaDB, use this command:
sudo mariadb
bashThis command enables you to check which version number of MariaDB is being used:
> SELECT version();
sqlTo uninstall MariaDB on Debian 12, simply use the following command:
sudo apt purge mariadb-server
bashAs a last step, press [Y] and [Enter] to confirm that you really want to delete the server completely. MariaDB will then be removed from your system.