MariaDB 10.11 Installation - Debian 12 (bookworm)

This article describes how to install MariaDB 10.11 on Debian 12 (bookworm).


This article uses an official MariaDB mirror (mirror.creoline.net). https://mirmon.mariadb.org/#de



Preparation

To install MariaDB, first update the local repositories.


apt-get update && apt-get dist-upgrade



Add the APT Repository

The official Debian repositories currently include the MariaDB server package, version 10.5, in Debian 11. To use the latest version of MariaDB, an additional APT repository must be installed.


# Create a new source list
echo "deb [arch=amd64] https://mirror.creoline.net/mariadb/repo/10.11/debian bookworm main" | tee /etc/apt/sources.list.d/mariadb.list

# Add the public key
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 F1656F24C74CD1D8

# Update APT repositories
apt-get update


Display MariaDB 10.11 Server Information

Before starting the installation, you can use apt info to verify which package will actually be installed.


apt info mariadb-server
Package: mariadb-server
Version: 1:10.11.1+maria~deb11   <-------
Priority: optional
Section: database
Source: mariadb-10.11
Maintainer: MariaDB Developers <maria-developers@lists.launchpad.net>
Installed-Size: 10.2 kB
Depends: mariadb-server-10.8 (>= 1:10.8.4+maria~deb11)
Homepage: https://mariadb.org/
Download Size: 2,832 B

APT Sources: https://mirror.creoline.net/mariadb/repo/10.8/debian bullseye/main amd64 Packages

Description: MariaDB database server (metapackage depending on the latest version) [...]


You can then install the MariaDB server:


apt-get install mariadb-server


Reading package lists… Done
Building dependency tree… Done
Reading status information… Done
The following additional packages will be installed:
  galera-4 gawk libcgi-fast-perl libcgi-pm-perl libclone-perl libconfig-inifiles-perl libdaxctl1
  libdbd-mariadb-perl libdbi-perl libencode-locale-perl libfcgi-bin libfcgi-perl libfcgi0ldbl
  libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl
  libio-html-perl liblwp-mediatypes-perl libmariadb3 libmpfr6 libndctl6 libpmem1 libsigsegv2
  libterm-readkey-perl libtimedate-perl liburi-perl mariadb-client-10.8 mariadb-client-core-10.8
  mariadb-common mariadb-server-10.8 mariadb-server-core-10.8 mysql-common psmisc rsync socat
Suggested packages:
  gawk-doc libmldbm-perl libnet-daemon-perl libsql-statement-perl libdata-dump-perl
  libipc-sharedcache-perl libwww-perl mailx mariadb-test netcat-openbsd
The following NEW packages will be installed:
  galera-4 gawk libcgi-fast-perl libcgi-pm-perl libclone-perl libconfig-inifiles-perl libdaxctl1
  libdbd-mariadb-perl libdbi-perl libencode-locale-perl libfcgi-bin libfcgi-perl libfcgi0ldbl
  libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl
  libio-html-perl liblwp-mediatypes-perl libmariadb3 libmpfr6 libndctl6 libpmem1 libsigsegv2
  libterm-readkey-perl libtimedate-perl liburi-perl mariadb-client-10.8 mariadb-client-core-10.8
  mariadb-common mariadb-server mariadb-server-10.8 mariadb-server-core-10.8 mysql-common psmisc rsync
  socat
0 packages to update, 38 new packages to install, 0 packages to remove, and 0 packages not to update.
31.3 MB of archives need to be downloaded.
After this operation, an additional 225 MB of disk space will be used.
Do you want to continue? [Y/n]


The installation can be confirmed by pressing Enter, Y, or J.


After installation, you can check the automatic Systemd status when the server starts using the following command:


systemctl is-enabled mariadb
enabled


You can also view the current service status using systemctl status mariadb:


root@db02:/# systemctl status mariadb

● mariadb.service - MariaDB 10.11.1 database server
 Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/mariadb.service.d
 └─migrated-from-my.cnf-settings.conf
 Active: active (running) since Thu 2022-09-01 13:24:05 CEST; 3 min 8 s ago
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
    Process: 3280 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
    Process: 3281 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 3283 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [>
    Process: 3329 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 3331 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
   Main PID: 3312 (mariadbd)
 Status: "Taking your SQL requests now..."
      Tasks: 9 (limit: 4678)
 Memory: 207.7M
 CPU: 514ms
 CGroup: /system.slice/mariadb.service
 └─3312 /usr/sbin/mariadbd




Securing the MariaDB Server

After MariaDB has been successfully installed, you can use mysql_secure_installation to remove the anonymous MySQL user. Additionally, secure socket authentication can be enabled.


mysql_secure_installation


Setting Default Description
Switch to unix_socket authentication [Y/n] Unix socket authentication maps the Unix-based login for root@localhost.
Change the root password? [Y/n] Change the MySQL root user password
Remove anonymous users? [Y/n] Removes all anonymous users
Disallow root login remotely? [Y/n] Disables remote login as the root user. (Remote means anything other than @localhost or 127.0.0.1)
Remove test database and access to it? [Y/n] Removes all test databases and permissions
Reload privilege tables now? [Y/n] Reload all privileges




Common Issues with MariaDB Installation


Missing SSH key for repository signing

Error message: NO_PUBKEY F1656F24C74CD1D8


Full error message:

root@mariadb:/etc/apt/sources.list.d# apt update

OK:1 https://mirror.creoline.net/debian bullseye InRelease
OK:2 https://mirror.creoline.net/debian-security bullseye-security InRelease
OK:3 https://mirror.creoline.net/debian bullseye-updates InRelease

Retrieving:4 https://mirror.creoline.net/mariadb/repo/10.8/debian bullseye InRelease [4,637 B]
Failed:4 https://mirror.creoline.net/mariadb/repo/10.8/debian bullseye InRelease
The following signatures could not be verified because their public key 
is not available: NO_PUBKEY F1656F24C74CD1D8
Reading package lists… Done

W: GPG error: https://mirror.creoline.net/mariadb/repo/10.8/debian bullseye InRelease: 
The following signatures could not be verified because their public key 
is not available: NO_PUBKEY F1656F24C74CD1D8

E: The repository “https://mirror.creoline.net/mariadb/repo/10.8/debian bullseye InRelease” is 
not signed.

N: Updating from such a repository cannot be performed securely, 
so it is disabled by default.
N: For more details on creating package repositories and configuring them, 
see the apt-secure(8) manual page.


Solution:

Add the public key to your local GPG client.


apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 F1656F24C74CD1D8
gpg: Key F1656F24C74CD1D8: 
Public key "MariaDB Signing Key <signing-key@mariadb.org>" imported

gpg: Total number of keys processed: 1
gpg: imported: 1