Guides 11792 Published by

The article explains how to install the latest MariaDB 10.x on Debian 11 (bullseye) or Debian 10 (buster) by adding the official MariaDB repository instead of using the distribution’s built‑in packages, which are locked to older releases. It walks through verifying the OS version, importing the GPG key with curl and gpg, configuring a repo file for either bullseye or buster while letting readers swap in their preferred sub‑release or mirror, then updating apt and installing mariadb-server. After installation, the guide recommends running mysql_secure_installation to set a root password, remove anonymous users, block remote root access, and clean up test databases, followed by checking the service status and offering optional configuration tweaks such as changing the data directory or binding only to localhost. The author wraps up with a real‑world anecdote about a client who had dependency problems after upgrading Debian versions, illustrating how using the upstream repo resolves such issues and ensures access to security patches.



How to Install MariaDB 10.x on Debian 11 or 10

In this quick guide you’ll learn how to pull the latest 10.x MariaDB out of the official repo and get it running on a fresh Debian 11 (bullseye) or Debian 10 (buster). No more hunting through backports or dealing with broken dependencies – just a few commands, a bit of explanation, and you’re done.

Why the Official Repo Beats the Default Packages

Debian ships with MariaDB 10.5 on bullseye by default, but that version is locked in for the life of the release. If your project needs 10.6 or 10.7 (or you just want the newest features), the built‑in packages will hold you back. Adding the official MariaDB repository gives you a clean upgrade path and access to all supported 10.x releases.

Step 1: Verify Your Distribution
lsb_release -a   # or cat /etc/os-release

This tells you whether you’re on buster (Debian 10) or bullseye (Debian 11). The repo URL changes based on that.

Step 2: Import the MariaDB GPG Key
sudo apt install gnupg  # make sure you have gnupg installed
curl -LsS https://mariadb.org/mariadb_release_signing_key.asc | sudo gpg --dearmor -o /usr/share/keyrings/mariadb-archive-keyring.gpg

Adding the key ensures apt trusts packages from MariaDB. Without it you’ll hit a “NO_PUBKEY” error the moment you try to update.

Step 3: Add the Correct Repository
# For Debian 11 (bullseye)
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/mariadb-archive-keyring.gpg] https://mirrors.ustc.edu.cn/mariadb/repo/10.6/debian bullseye main" | sudo tee /etc/apt/sources.list.d/mariadb.list

# For Debian 10 (buster)
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/mariadb-archive-keyring.gpg] https://mirrors.ustc.edu.cn/mariadb/repo/10.6/debian buster main" | sudo tee /etc/apt/sources.list.d/mariadb.list

Replace 10.6 with whatever 10.x sub‑release you prefer (e.g., 10.7). The mirror URL can be swapped for your region; just keep the repo format.

Step 4: Update APT and Install MariaDB
sudo apt update
sudo apt install mariadb-server

apt update pulls metadata from the newly added repo, so you’ll get the 10.x binaries instead of the older Debian defaults. mariadb-server pulls in everything you need: the daemon, client libraries, and the test suite.

Step 5: Harden the Installation
sudo mysql_secure_installation

You’ll be asked a handful of questions:

1. Set root password – If you skip this on Debian, MariaDB starts without a root password by default. That’s a nightmare for production systems.

2. Remove anonymous users – I’ve seen this cause “Access denied” errors when the first developer logs in with a non‑root account.

3. Disallow remote root login – A common oversight that turns your local database into an open door.

4. Remove test database & reload privileges – The default test db is nothing but a reminder of how easy it is to create a new MySQL instance without any security hardening.

Each prompt is there for a reason; don’t skip them unless you have a specific setup that requires it.

Step 6: Check the Service Status
systemctl status mariadb

You should see “active (running)”. If it’s stuck in a boot loop, check /var/log/mysql/error.log for clues – often a mis‑configured my.cnf will cause the daemon to crash on startup.

Step 7: Optional Tweaks for Your Use Case
  • Change the data directory: If you have more disk space elsewhere or need a larger table size, edit /etc/mysql/mariadb.conf.d/50-server.cnf and set datadir = /mnt/data/db. Remember to move existing files with mv /var/lib/mysql/* /mnt/data/db/.
  • Bind to localhost only: In the same file, change bind-address = 127.0.0.1 if you don’t want external connections.

After any changes, restart:

sudo systemctl restart mariadb
Real‑World Scenario That Saves Your Day

I once had a client on Debian 9 who upgraded to Debian 10 but kept the old 5.5 MariaDB from their previous repo. When they ran apt install mariadb-server, apt complained about unsatisfied dependencies because the new packages expected newer libs. Adding the official MariaDB 10.x repo fixed it instantly and gave them the latest security patches. Lesson learned: always use the upstream repository for major database upgrades, not the distribution’s default.

That’s all you need to get MariaDB 10.x up and running on Debian 11 or 10.