Install MariaDB on Debian 12 Bookworm

In this guide, we want to teach you to Install MariaDB on Debian 12 Bookworm. MariaDB is a popular relational database management. Debian 12 ships with the current stable version of MariaDB which is 10.11.

Steps To Install MariaDB Database Management on Debian 12 Bookworm

To complete this guide, you must log in to your server as a non-root user with sudo privileges. To do this, you can visit this guide on Initial Server Setup with Debian 12 Bookworrm.

Step 1 – Install MariaDB from CLI on Debian 12

First, you must run the system update with the command below:

sudo apt update

Then, use the following command to install MariaDB on your server:

sudo apt install mariadb-server -y

Your MariaDB service must be activated during the installation. To verify it, you can use the command below:

sudo systemctl status mariadb
‚óŹ mariadb.service - MariaDB 10.11.3 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; preset: enab>
     Active: active (running) since Thu 2023-06-15 08:27:21 EDT; 51s ago
       Docs: man:mariadbd(8)
   Main PID: 28617 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 15 (limit: 4653)
     Memory: 183.2M
        CPU: 818ms
     CGroup: /system.slice/mariadb.service

Step 2 – Manage MariaDB Service on Debian 12

At this point, you can manage your MariaDB service via systemctl. To start your MariaDB server on Debian 12, you can use the command below:

sudo systemctl start mariadb

To enable it, you can execute the following command:

sudo systemctl enable mariadb

You can stop your MariaDB service by using the command below:

sudo systemctl stop mariadb

To restart your service, you can run the command below:

sudo systemctl restart mariadb

Step 3 – Run MariaDB Security Script on Debian 12

For security reasons, it is recommended to run the security script by using the command below:

sudo mysql_secure_installation

You will be asked some questions, answer them as shown below and change your MariaDB root password with a strong password:

Enter current password for root (enter for none):
OK, successfully used password, moving on...
Switch to unix_socket authentication [Y/n] n
Change the root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

Remove anonymous users? [Y/n] y
 ... Success!

Disallow root login remotely? [Y/n] y
 ... Success!

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

At this point, you can access your MariaDB shell by using the command below:

sudo mariadb -u root -p

Enter your password and you should access your shell as shown below:

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 39
Server version: 10.11.3-MariaDB-1 Debian 12

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

Step 4 – Start To Use MariaDB Server

Now we want to show you a basic usage of MariaDB on Debian 12 by creating a database and user.

Run the following command from your MariaDB console to create a new database:

MariaDB [(none)]> CREATE DATABASE orca_database;

Here you can create a new user and give them full privileges on the database you have just created.

Run the following command to create the user and replace the password with a secure password of your own:

MariaDB [(none)]> GRANT ALL ON orca_database.* TO 'olivia_user'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;

Now you need to be sure that they are saved and available in the current session. Flush the privileges with the following command:


Then verify that the user has access to the orca_database database with the following command:

MariaDB [(none)]> SHOW DATABASES;

In your output, you will see:

| Database           |
| information_schema |
| mysql              |
| orca_database      |
| performance_schema |
| sys                |
5 rows in set (0.003 sec)

Now you can exit from your MariaDB shell by using the command below:

MariaDB [(none)]> EXIT;

For more information, you can visit MariaDB Documentation.


At this point, you have learned to Install the MariaDB database management system on Debian 12 Bookworm. You also learned to manage MariaDB service and secure your installation by running a security script. And you have learned to create a user database with MariaDB.

Hope you enjoy it. You may like these articles too:

Install MariaDB 10.11 on AlmaLinux 9

Install MariaDB 10.11 on Ubuntu 22.04

Reset MySQL And MariaDB Root Password on Ubuntu 22.04


Please enter your comment!
Please enter your name here

Latest Articles


Most Popular