How To Install MariaDB on Debian 11
In this tutorial, we will show you how to install MariaDB on Debian 11. For those of you who didn’t know, MariaDB is a popular open-source relational database, developed by MySQL developers. Unlike MySQL, MariaDB was meant to be totally free to use. The original creators of MySQL developed MariaDB in response to fears that MySQL will suddenly become a paid service due to Oracle’s acquisition. With its history of doing similar tactics, the developers behind MariaDB have promised to keep it open source and free from such fears as what has happened to MySQL.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the MariaDB database on a Debian 11 (Bullseye).
Prerequisites
- A server running one of the following operating systems: Debian 11 (Bullseye).
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for MariaDB.
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install MariaDB on Debian 11 Bullseye
Step 1. Before we install any software, it’s important to make sure your system is up to date by running the following apt
commands in the terminal:
sudo apt update sudo apt upgrade sudo apt install software-properties-common dirmngr
Step 2. Installing MariaDB on Debian 11.
Now we add MariaDB signing key and APT repository:
wget https://mariadb.org/mariadb_release_signing_key.asc sudo chmod -c 644 mariadb_release_signing_key.asc sudo mv -vi mariadb_release_signing_key.asc /etc/apt/trusted.gpg.d/
Next, add the MariaDB repository manually on your Debian system:
echo "deb [arch=amd64,arm64,ppc64el] \ https://ftp.ubuntu-tw.org/mirror/mariadb/repo/10.6/debian \ bullseye main" | sudo tee /etc/apt/sources.list.d/mariadb.list
Once done, install MariaDB using the following command below:
sudo apt update sudo apt install mariadb-server
Confirm the installation of MariaDB by checking the version and build:
mariadb --version
Now run the following commands to start MariaDB and enable it to automatically start on system reboot:
sudo systemctl start mariadb sudo systemctl enable mariadb
Step 3. Secure MariaDB installation.
By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation
script. you should read and below each step carefully which will set a root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MariaDB:
mysql_secure_installation
Configure it like this:
- 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
You can now connect to the MariaDB server using the new password:
mysql -u root -p
Congratulations! You have successfully installed MariaDB. Thanks for using this tutorial for installing the latest version of MariaDB 10.6 on Debian 11 Bullseye. For additional help or useful information, we recommend you check the official MariaDB website.