Install, Setup MariaDB and Create Database on Debian 11 Bullseye

MariaDB is a popular and widely used data-based server introduced as an ideal alternative to MySQL server. You can use this database system to create a web server or develop applications. Several cloud-based servers consider the MariaDB database as a top performance because of its easy setup features that can be performed by a beginner as well.

As a Debian user, you can install MariaDB on the system from this article’s guidelines.

How to Install MariaDB on Debian

To install MariaDB on Debian, you must follow the steps given below:

Step 1: Update the Debian Repository

First, it’s good to update the Debian repository with the following commands:

sudo apt update
sudo apt upgrade


Step 2: Install MariaDB

After updating the Debian repository, you can install MariaDB via the command given below:

sudo apt install mariadb-server -y


Step 3: Configure MariaDB

After completing the MariaDB installation, ensure securing its service before creating the database and for that, you should run the following command:

sudo mysql_secure_installation


You should enter the login password and then reply with “y” and “n” according to their choice on the options appears on the terminal.

Step 4: Create a Database Using MariaDB

To know how to create a MariaDB database on Debian, you must run the following command:

sudo mysql


Then you can create a database through MariaDB on Debian from the following syntax:

create database <mydatabase>;


You must replace the <mydatabase> with the name of your choice.

To confirm whether the database is successfully created on Debian, run the following command:

show databases;


Then use the syntax shown below to create a username and password for your Database.

GRANT ALL PRIVILEGES ON <mydatabase>.* TO '<user_name>'@'localhost' IDENTIFIED BY '<password>';


Note: Don’t forget to use your own username and password.

You have to flush the privileges table for the changes to be applied using the following syntax:



Then exit the MariaDB database by entering the exit command.



After completing the above instructions, you will now have created a MariaDB database on Debian.


MariaDB installation and setup are simple on Debian. For installation, you can use the “apt” command that quickly installs the server from the Debian repository. Then you have to secure the server using the “my_secure_installation” command. After that, you can run the “sudo mysql” command and create your own MariaDB database on Debian.

About the author

Awais Khan

I'm an Engineer and an academic researcher by profession. My interest for Raspberry Pi, embedded systems and blogging has brought me here to share my knowledge with others.