Install MariaDB 10.6 on Debian 11

Follow through this guide to learn how to install MariaDB 10.6 on Debian 11.

Install MariaDB 10.6 on Debian 11

Add MariaDB APT Repository

Debian 11 main repositories provide MariaDB 10.5. Hence, to install MariaDB 10.6, you need to add APT repisitories.

Install required packages to add the repository:

apt install software-properties-common dirmngr -y

Download repository signing key;

wget https://mariadb.org/mariadb_release_signing_key.asc -P /etc/apt/trusted.gpg.d/

Next, install the MariaDB apt repository;

add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.6/debian bullseye main'

Btw, you can choose your preferred install mirror from MariaDB repositories page.

Install MariaDB 10.6 on Debian 11

Next, run system update and install MariaDB 10.6 on Debian 11.

apt update
apt install mariadb-server -y

Running MariaDB

The install command starts and enable MariaDB to run on boot, upon completing the installation.

systemctl status mariadb
● mariadb.service - MariaDB 10.5.11 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2021-08-22 08:31:11 EAT; 2min 37s ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 2579 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
    Process: 2580 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 2582 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-en>
    Process: 2641 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 2643 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
   Main PID: 2629 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 12 (limit: 1133)
     Memory: 80.5M
        CPU: 1.130s
     CGroup: /system.slice/mariadb.service
             └─2629 /usr/sbin/mariadbd

Aug 22 08:33:43 debian11 /etc/mysql/debian-start[2648]: Processing databases
Aug 22 08:33:43 debian11 /etc/mysql/debian-start[2648]: information_schema
Aug 22 08:33:43 debian11 /etc/mysql/debian-start[2648]: mysql
Aug 22 08:33:43 debian11 /etc/mysql/debian-start[2648]: performance_schema
Aug 22 08:33:43 debian11 /etc/mysql/debian-start[2648]: Phase 6/7: Checking and upgrading tables
Aug 22 08:33:43 debian11 /etc/mysql/debian-start[2648]: Processing databases
Aug 22 08:33:43 debian11 /etc/mysql/debian-start[2648]: information_schema
Aug 22 08:33:43 debian11 /etc/mysql/debian-start[2648]: performance_schema
Aug 22 08:33:43 debian11 /etc/mysql/debian-start[2648]: Phase 7/7: Running 'FLUSH PRIVILEGES'
Aug 22 08:33:43 debian11 /etc/mysql/debian-start[2648]: OK

You can manage the service as any other systemd service unit.

Run MariaDB Secure Script

Next, run the initial security script to remove test databases, disable remote root login, remove anonymous users.

mysql_secure_installation

Follow the prompts and answer them accordingly.

Enable MariaDB Password Authentication

MariaDB 10.6 uses unix_socket authentication plugin by default. This allows the user to use operating system credentials when connecting to MariaDB via the local Unix socket file.

Anyone with sudo rights or access to root system account can login to MariaDB.

To switch back to password based authentication;

Login to MariaDB;

mysql

Run the command;

ALTER USER root@localhost IDENTIFIED VIA mysql_native_password;

Set root user password. Replace password with your secure password.

SET PASSWORD = PASSWORD('password');

Reload privileges tables and exit database connection;

flush privileges;
quit

Confirm that password based authentication has been enabled;

mysql

If you get such output as, ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO), then all is well.

Check the version of installed MariaDB;

mysql -V
mysql  Ver 15.1 Distrib 10.6.4-MariaDB, for debian-linux-gnu (x86_64) using readline EditLine wrapper

You can now start creating your databases.

That brings our guide on how to install MariaDB 10.6 on Debian 11 to a close.

Further Reading

MariaDB Documentation

Other Tutorials

Install Nginx on Debian 11

Install Apache HTTP Server on Debian 11

Install Debian 11 Bullseye on VirtualBox

Install Usermin on Rocky Linux 8

Founder of itnixpro.com|Linux Engineer|Author at Itnixpro.com

Leave a Comment