How to Install MariaDB on Debian 12 Bookworm Distribution


MariaDB is a reliable, open-source, and commonly used relational database management system that serves as a drop-in replacement for MySQL. In this article, we will provide you with a comprehensive, plagiarism-free guide on how to install MariaDB on Debian 12. By following these steps, you can ensure a smooth installation process and have MariaDB up and running in no time.

This guide will explain to you how to install MariaDB on Debian 12 Bookworm Linux distribution using the command line.

Step 1: Update Debian 12 packages

Before installing any software, it is good practice that all users update their Debian 12 system to the latest packages and dependencies. Open the terminal and run the following command:

$ sudo apt update

$ sudo apt upgrade

Step 2: Install MariaDB on Debian 12

Once your system is up to date, you can proceed with the MariaDB installation. MariaDB version 10 is available for installation in the default Debian 12 repository. To verify it using this command:

$ sudo apt show mariadb-server

As we can see, MariaDB 10 is available in the Debian 12 repository. So, enter the following command in the terminal to initiate the installation process:

$ sudo apt install mariadb-server -y

During the installation, you will be prompted to enter your user password. Provide the necessary information, and the MariaDB installation will continue on your system.

Step 3: Secure the MariaDB Installation

After the installation completes, it is important to secure your MariaDB installation. To enhance the security of your MariaDB installation, the default security script comes bundled with MariaDB. The below-given command will run a script that performs some security measures:

$ sudo mariadb-secure-installation

When executing the above script, you will be taken through a series of interactive prompts designed to strengthen the security of your MariaDB installation. These prompts include:

Setting a root password: You will have the opportunity to set a password for the root account, providing an additional layer of protection.

Removing anonymous users: The script will help you remove any anonymous user accounts, ensuring that only authenticated users can access the databases.

Disallowing remote root login: You will be prompted to disable remote root login, preventing potential unauthorized access from external sources.

Removing the test database: The script assists in removing the test database, which is typically accessible to anonymous users. This action eliminates any potential security vulnerabilities associated with the test database.

Reloading privilege tables: Once the necessary security measures are implemented, the script reloads the privilege tables to apply the changes effectively.

Throughout the process, carefully follow the prompts presented by the script and provide the appropriate responses to enhance the security of your MariaDB installation.

Step 4: Verify MariaDB installation

Once the MariaDB installation is complete, the MariaDB service automatically starts on your system. You can check the running status of the MariaDB service with this command:

$ sudo systemctl status mariadb

Step 5: Accessing MariaDB

With the installation and security setup complete, you can now access MariaDB. Use the following command to access the MariaDB shell:

$ sudo mariadb

You will be greeted with the MariaDB shell prompt.

Step 6: Display MariaDB Version

To check whether MariaDB is installed correctly and working on your system. You can run a simple command within the MariaDB shell. Execute the following command:

> SELECT version();

If MariaDB is installed correctly, you will see the version number displayed in the output.

Uninstall MariaDB from Debian 12

To remove the MariaDB databases and configuration, type the following command:

$ sudo apt purge mariadb-server

To see how MariaDB works, you can visit its MariaDB documentation from official website.

Conclusion

The above steps will help you in installing the MariaDB on Debian 12. Remember to update your system, install MariaDB, secure the installation, and verify it’s working. With MariaDB up and running, you can enjoy the benefits of a powerful and reliable relational database management system for your applications and projects.

Print Friendly, PDF & Email
Categories