MariaDB 10.7

How to Install MariaDB 10.7 on Debian 11

MariaDB is an open-source relational database management system developed by the developers of MySQL as an enhanced drop-in replacement to the MySQL server. MariaDB is focused on reliability, stability, security, and performance.

In this tutorial, we will show you the complete steps to install MariaDB 10.7 on Debian 11 from an APT repository.

Update Operating System

Update your Debian 11 operating system to make sure all existing packages are up to date:

$ sudo apt update && sudo apt upgrade -y

Install Dependencies

Install the required packages for the installation of MariaDB 10.7 with the following command:

$ sudo apt install curl software-properties-common dirmngr gnupg2

Add MariaDB 10.7 Repository

MariaDB 10.5 is the currently available version on the default Debian 11 repositories. To be able to install MariaDB 10.7 on Debian 11 you need to add the MariaDB 10.7 APT repository:

$ curl -LsS | sudo bash -s -- --mariadb-server-version=10.7 --skip-maxscale --skip-tools

Install MariaDB 10.7

Once the repository has been added to the system, You are now ready to install MariaDB 10.7 with the following command:

$ sudo apt install mariadb-server mariadb-client

You can verify the installed version of MariaDB with the following command:

$ mariadb --version


mariadb Ver 15.1 Distrib 10.7.1-MariaDB, for debian-linux-gnu (x86_64) using readline EditLine wrapper

Start the database server daemon, and also enable it to start automatically at the next boot with the following commands:

$ systemctl start mariadb
$ systemctl enable mariadb

Check the status of the service:

$ systemctl status mariadb

Example output:

$  mariadb.service - MariaDB 10.7.1 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/mariadb.service.d
Active: active (running) 
Docs: man:mariadbd(8)
 Process: 3274 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
Process: 3276 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 3278 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ] && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, stat>
Process: 3340 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 3342 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
Main PID: 3326 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 13 (limit: 2301)
Memory: 68.1M
CPU: 345ms
CGroup: /system.slice/mariadb.service
└─3326 /usr/sbin/mariadbd

Secure MariaDB

Run mariadb-secure-installation script which helps you secure your MariaDB database server:

$ sudo mariadb-secure-installation

You can set a root password for MariaDB along with removing empty databases, restricting remote access except for localhost, removing anonymous users, and more:

Set root password? [Y/n] Y
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

MariaDB Create Database

We need to login to MariaDB with the following command:

$ sudo mysql -u root -p

Note: Use -p if you have set the root password.

To create a database in MariaDB you need to run the following command:

MariaDB [(none)]> CREATE DATABASE your_db;

View the new database:


show databases

To create a new MariaDB user, run the following command:

MariaDB [(none)]> CREATE USER 'your_user'@localhost IDENTIFIED BY 'password';

You should replace password with a secure password.

View the new user:

SELECT User FROM mysql.user;

show users

The newly created user does not have privileges to manage databases.

Create a new user (only with local access) and grant privileges to this user on the database:

MariaDB [(none)]> GRANT ALL PRIVILEGES ON your_db.* TO 'your_user'@'localhost' IDENTIFIED BY 'password';

Create a new user (with remote access) and grant privileges to this user on the database:

MariaDB [(none)]> GRANT ALL PRIVILEGES ON your_db.* TO 'your_user'@'%' IDENTIFIED BY 'password';

Flush the privileges:


Exit the MariaDB shell:

MariaDB [(none)]> exit

Reset the MariaDB Root Password

If you forget your root MariaDB password, it can be reset.

Stop the MariaDB server:

$ sudo systemctl stop mariadb

Start the database without loading the grant tables or enabling networking:

$ sudo systemctl set-environment MYSQLD_OPTS="--skip-grant-tables --skip-networking"

Restart MariaDB:

$ sudo systemctl start mariadb

Now you can connect to the database as the root user,:

$ sudo mysql -u root

Use the following commands to reset root’s password. Replace password with a strong password:

MariaDB [(none)]> UPDATE mysql.user SET password = PASSWORD('password') WHERE user = 'root';

Update the authentication methods for the root password:

MariaDB [(none)]> UPDATE mysql.user SET authentication_string = '' WHERE user = 'root';
MariaDB [(none)]> UPDATE mysql.user SET plugin = '' WHERE user = 'root';

Revert the environment settings to allow the database to start with grant tables and networking:

$ sudo systemctl unset-environment MYSQLD_OPTS

Then restart MariaDB:

$ sudo systemctl start mariadb

You should now be able to log into the database with your new root password:

$ sudo mysql -u root -p

Comments and Conclusion

That’s it. You have successfully installed MariaDB 10.7 on Debian 11. Also, In the tutorial, you have learned how to create database and reset your MariaDB root password.

For additional help or useful information, we recommend you to check the official MariaDB documentation.

If you have any questions please leave a comment below.

6 thoughts on “How to Install MariaDB 10.7 on Debian 11

Leave a Reply

Your email address will not be published. Required fields are marked *