How to Install MariaDB on Debian 11. MariaDB is one of the most widely used database software built over MySQL and used for several well-known applications that utilize like WordPress and many more.
In this guide you are going to learn how to install latest MariaDB community server on Debian.
This setup is tested on Google cloud, so it will work on all cloud hosting services like AWS, Azure or any VPS or any dedicated servers running Debian 11.
- Root access to your server or a sudo user.
Step 1: Setup Initialization
Start by updating the packages to the latest version available using the following command.
sudo apt update sudo apt upgrade
Install wget package.
sudo apt install wget
Once you have updated the setup you can start the setup.
Step 2: Configure APT repository
By default Debian 11 repositories have the MariaDB package. But they may be outdated and doesn’t have the latest version. To install the latest available version you need to follow the below steps.
To add the MariaDB APT repository execute the following commands
wget https://downloads.mariadb.com/MariaDB/mariadb_repo_setup echo "b9e90cde27affc2a44f9fc60e302ccfcacf71f4ae02071f30d570e6048c28597 mariadb_repo_setup" | sha256sum -c -
Configure correct permissions.
chmod +x mariadb_repo_setup
Setup MariaDB version to install. Here we are using version 10.6 which the latest at the time of writing this tutorial.
sudo ./mariadb_repo_setup --mariadb-server-version="mariadb-10.6"
Update the package index and install MariaDB.
sudo apt update sudo apt install mariadb-server mariadb-client
Once the installation is completed, the MariaDB service will start automatically. To verify that the MariaDB server is running, type:
sudo service mariadb status
The output should show that the service is enabled and running:
● mariadb.service - MariaDB 10.6.7 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 Mon 2022-02-14 05:51:33 UTC; 29s ago Docs: man:mariadbd(8) https://mariadb.com/kb/en/library/systemd/ Process: 3823 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (> Process: 3824 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION > Process: 3826 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR> Process: 3870 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION> Process: 3872 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS) Main PID: 3855 (mariadbd)
Now you have installed the latest version of MariaDB server.
Step 3: Secure MariaDB
MariaDB installation comes with a script named
mysql_secure_installation that allows you to easily improve the MariaDB server security.
You will be asked to configure the
VALIDATE PASSWORD PLUGIN which is used to test the strength of the MariaDB users passwords and improve the security.
y if you want to set up the validate password plugin or any other key to move to the next step.
There are three levels of password validation policy, low, medium, and strong.
Enter 2 for strong password validation.
On the next prompt, you will be asked to set a password for the MariaDB root user.
If you set up the validate password plugin, the script will show you the strength of your new password. Type
y to confirm the password.
Next, you’ll be asked to remove the anonymous user, restrict root user access to the local machine, remove the test database, and reload privilege tables. You should answer
y to all questions.
Supercharge your Linux Administration Career with completed training course and get your dream job.
Now you have learned how to install MariaDB server on Debian 11 and secure it.
Thanks for your time. If you face any problem or any feedback, please leave a comment below.
Leave a Reply