Debian

How to install MariaDB on Debian 11

MariaDB is the RDMS (Relational Database Management System) and is used for managing the data of databases in the form of tables just like MySQL. The major difference between both is that MariaDB is written in Perl, Bash, C, C++, and MySQL is written only in C, C++. The updated features of MariaDB are its high-performance storage engine and working with other RDBMS easily. MariaDB is used by tech giants like Google and Mozilla.

In this write-up, we will learn the installation of MariaDB on Debian 11 using the command line method.

How to install MariaDB on Debian 11

We will learn the installation of the latest version of MariaDB that is 10.6 on Debian 11. Before installation we will update and upgrade the repository of Debian 11, to update.

$ sudo apt-get update

After the update, upgrade the repository so the packages which needed upgrading can be upgraded.

$ sudo apt-get upgrade

Install the dependency package of MariaDB.

$ sudo apt-get install software-properties-common dirmngr

We will import the key of the installation package of MariaDB from its official website.

$ sudo apt-key adv --fetch-keys ‘https://mariadb.org/mariadb_release_signing_key.asc’

The key which is imported now added to the repository of Debian 11 as

$ sudo add-apt-repository ‘deb https://mariadb.mirror.liquidtelecom.com/repo/10.6/debian bullseye main’

Update the repository again.

$ sudo apt-get update

Install MariaDB.

$ sudo apt-get install mariadb-client mariadb-server -y

Once the installation of MariaDB is complete, start and enable it. Start it with the command of systemctl.

$ sudo systemctl start mariadb

To enable it so that it can automatically start on reboot.

$ sudo systemctl enable mariadb

To verify the running status of MariaDB, we will check its status.

$ sudo systemctl status mariadb

It is confirmed from the status, MariaDB is successfully installed as well as running. Now to make it secure, we will execute the command.

$ sudo mysql_secure_installation

Set any password, for example, in our case we are setting the password. Once the password is set, a successful message will display and it will ask whether to switch to the unix_socket authentication, type “n”, because the unix_socket authentication is the passwordless security mechanism.

It will ask to change the root password, if you don’t want to change press “n”.

Next, it will ask for the removal of an anonymous user, type “Y” to remove them.

Type “Y”, to disallow root login remotely.

Remove the test database and access it by typing “Y”.

Reload the privileges table now by answering it with “Y”.

Now to verify the security we will run the following command to enter the environment of MariaDB and then type the set password to access it.

$ sudo mysql -u root -p

To check the version of MariaDB we will type.

SELECT VERSION();

Exit from MariaDB.

EXIT;

Conclusion

One of the reasons for the popularity of MariaDB is its compatibility with MySQL which allows its users to easily shift their databases from MySQL to MariaDB. This write-up is about the installation procedure of MariaDB on Debian 11 using the terminal. We simply imported the key from the official website of MariaDB and added it to the repository of Debian bullseye. After the installation, we started and enabled it and verified this by confirming its status. Finally, we configure its basic settings and run MariaDB to check its installed version.

About the author

Hammad Zahid

I'm an Engineering graduate and my passion for IT has brought me to Linux. Now here I'm learning and sharing my knowledge with the world.