Share your love
Install MariaDB on Debian 12 Bookworm: Easy Database Management

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. Now follow the steps below on the Orcacore website to Install MariaDB on Debian 12 Bookworm.
Table of Contents
Steps To Install MariaDB on Debian 12 Bookworm
To Install MariaDB on Debian 12 Bookworm, 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.
Now follow the steps below to Install MariaDB on Debian 12 Bookworm.
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 Debian 12 Bookworm:
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
Ouput
● 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)
https://mariadb.com/kb/en/library/systemd/
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:

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:
MariaDB [(none)]> FLUSH PRIVILEGES;
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:
Output
+--------------------+
| 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.
Conclusion
At this point, you have learned to Install MariaDB 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