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

  1. Update your system to the latest version.
  2. Install the database man­age­ment system.
  3. Configure MariaDB.
  4. Create an ad­di­tion­al admin if required.
  5. Check the in­stall­a­tion.

Why are MariaDB and Debian 10 a good com­bin­a­tion?

Have you compared MariaDB vs MySQL and decided in favour of the newer fork? You can also opt to use the database man­age­ment system as a MySQL al­tern­at­ive in the LAMP stack (Linux, Apache, MySQL and PHP, Python or Perl) with Debian. Since MariaDB is a drop-in re­place­ment, this has always been com­par­at­ively un­prob­lem­at­ic. In the meantime, however, Debian has fully switched to MariaDB and only delivers the cor­res­pond­ing packages.

Tip

In our Digital Guide you will also find in­struc­tions to install MariaDB on Debian 11 or install MariaDB on Debian 12. There is also a helpful guide for in­stalling MongoDB on Debian 10.

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. It is important that you have created a server with Debian 10 and have a non-root user with sudo priv­ileges. A powerful firewall should also be set up and activated in advance. Once these re­quire­ments have been met, you can begin with the in­stall­a­tion process.

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 10 step by step

The following steps explain how to go about in­stalling MariaDB on Debian 10.

Step 1: Update the system

The first step is to update your package index to ensure that you are working with the latest versions. You can do this using the following apt commands:

sudo apt update
sudo apt upgrade
bash

Your Debian 10 in­stall­a­tion should now be up to date.

Step 2: Install MariaDB on Debian 10

You can then install MariaDB. In Debian 10, version 10.3 is included in the package re­pos­it­ory by default, as it is now treated as the preferred MySQL option. To install the package, use the following command:

sudo apt install mariadb-server
bash

Step 3: Configure MariaDB security settings

Although you have installed the essential MariaDB program files on Debian 10, there are currently no security measures or suitable con­fig­ur­a­tion in place. To protect your data and system, the MariaDB package includes a script that helps you regulate server access and remove unused accounts. To apply these changes, use the following script:

sudo mysql_secure_installation
bash

In the first step, you will be asked for your root password. As you have not yet set a password, press [Enter]. You then have the option of creating a new password. However, as the MariaDB root account is closely linked to various automated main­ten­ance and ad­min­is­tra­tion tasks, you should not change the au­then­tic­a­tion at this point. Otherwise, in the worst-case scenario, updates may remove your ad­min­is­tra­tion rights. Therefore, type [N] and then press [Enter] again.

You can respond to all the remaining prompts with [Y] and confirm by pressing [Enter]. By default, the test database and some anonymous users will be removed. Ad­di­tion­ally, remote root logins will be disabled.

Step 4: Create an admin account (optional)

The following step is optional. Since the root user of MariaDB on Debian uses unix_socket instead of a password for au­then­tic­a­tion by default, problems can occur with external programs as soon as they require ad­min­is­trat­ive rights. It therefore makes sense to set up an admin account in addition to the root account, which is used for access with a password. This is given the same rights as the root account but is con­figured for use with password pro­tec­tion. To do this, take the following steps.

Open MariaDB:

sudo mariadb -u root
bash

Then create a new user with root priv­ileges and a password. You can choose the username and password yourself.

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

Now use ‘FLUSH PRIV­ILEGES’ so that the changes are applied im­me­di­ately:

FLUSH PRIVILEGES;
sql

Finally, exit the shell:

exit
bash

Step 5: Check MariaDB

In the last step, check whether MariaDB runs properly and auto­mat­ic­ally after being installed on Debian 10. To do this, use the following command:

sudo systemctl status mariadb
bash

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

sudo systemctl start mariadb
bash

Now you can use MariaDB.

Go to Main Menu