MariaDB is a popular replacement for MySQL. While they offer a one-script installer for their official package repository, it uses deprecated key management practices. Additionally, if we want to use Apt Cacher NG to cache packages, we must change the repo URL to use HTTP instead of HTTPS.
Add apt cache proxy (optional)
echo 'Acquire::http::Proxy "http://apt-proxy.example.com:3142/";' | tee /etc/apt/apt.conf.d/00aptproxy
apt-get updateInstall prerequisites
apt-get install -y curl gpg sudoDownload keys
I wasn't happy with the use of the now-deprecated apt-key, so I dug through the file, found the GPG URLs, and gave the proper way a shot.
curl -fsSL https://supplychain.mariadb.com/MariaDB-Server-GPG-KEY | sudo gpg --dearmor -o /usr/share/keyrings/mariadb-server.gpgAdd source file and update apt
Add sources to /etc/apt/sources.list.d/mariadb.source by running to following directly on the command line:
Debian 12 (Bookworm)
## Add MariaDB apt source
cat << EOF | sudo tee /etc/apt/sources.list.d/mariadb.sources &> /dev/null
# MariaDB 12 repository list - created 2026-03-14 16:55 UTC
# https://mariadb.org/download/
X-Repolib-Name: MariaDB
Types: deb
URIs: http://deb.mariadb.org/12.rolling/debian
Suites: bookworm
Components: main
Signed-By: /usr/share/keyrings/mariadb-server.gpg
EOF
## Update apt
apt-get updateDebian 13 (Trixie)
## Add MariaDB apt source
cat << EOF | sudo tee /etc/apt/sources.list.d/mariadb.sources &> /dev/null
# MariaDB 12 repository list - created 2026-03-14 16:55 UTC
# https://mariadb.org/download/
X-Repolib-Name: MariaDB
Types: deb
URIs: http://deb.mariadb.org/12.rolling/debian
Suites: trixie
Components: main
Signed-By: /usr/share/keyrings/mariadb-server.gpg
EOF
## Update apt
apt-get updateInstall packages
Now we can install MariaDB server:
apt-get install mariadb-server mariadb-client mariadb-backupFinish installation
We'll secure our installation by running the following command and completing the prompts:
mysql_secure_installationStart enjoying your new MariaDB server.