How to install MariaDB on Debian 10

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 management system.
  3. Configure MariaDB.
  4. Create an additional admin if required.
  5. Check the installation.

Why are MariaDB and Debian 10 a good combination?

Have you compared MariaDB vs. MySQL and decided in favor of the newer fork? You can also opt to use the database management system as a MySQL alternative in the LAMP stack (Linux, Apache, MySQL and PHP, Python or Perl) with Debian. Since MariaDB is a drop-in replacement, this has always been comparatively unproblematic. In the meantime, however, Debian has fully switched to MariaDB and only delivers the corresponding packages.

Tip

In our Digital Guide you will also find instructions to install MariaDB on Debian 11 or install MariaDB on Debian 12. There is also a helpful guide for installing MongoDB on Debian 10.

What requirements must be met?

There are only a few requirements that need to be met to install MariaDB installation on Debian. It is important that you have created a server with Debian 10 and have a non-root user with sudo privileges. A powerful firewall should also be set up and activated in advance. Once these requirements have been met, you can begin with the installation process.

Compute Engine
The ideal IaaS for your workload
  • Cost-effective vCPUs and powerful dedicated cores
  • Flexibility 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 installing 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 installation 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 repository 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 configuration 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 maintenance and administration tasks, you should not change the authentication at this point. Otherwise, in the worst-case scenario, updates may remove your administration 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. Additionally, 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 authentication by default, problems can occur with external programs as soon as they require administrative 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 configured for use with password protection. To do this, take the following steps.

Open MariaDB:

sudo mariadb -u root
bash

Then create a new user with root privileges 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 PRIVILEGES’ so that the changes are applied immediately:

FLUSH PRIVILEGES;
sql

Finally, exit the shell:

exit
bash

Step 5: Check MariaDB

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

sudo systemctl status mariadb
bash

If MariaDB does not start automatically, use this command:

sudo systemctl start mariadb
bash

Now you can use MariaDB.

Was this article helpful?
We use cookies on our website to provide you with the best possible user experience. By continuing to use our website or services, you agree to their use. More Information.
Page top