MariaDB, an open-source RDBMS developed as a community-driven clone of the MySQL database system, is widely used. The system’s optimized speed, dependability, and scalability have made it a favorite among developers of cutting-edge online apps.
Michael “Monty” Widenius, the creator of MySQL, established MariaDB out of reluctance to support Oracle’s takeover of MySQL. He felt that the MySQL project’s future was in jeopardy while being managed by Oracle and that the open-source community need a more stable option.
MariaDB was built to be 100% compatible with MySQL, therefore migrating from MySQL to MariaDB is a simple process that won’t require any changes to your current databases or programs. Improved security, more sophisticated analytics tools, and enhanced clustering support are just a few of the many features and additions that set it apart from MySQL.
One of the key advantages of MariaDB over other database management systems is its high performance. It is designed to provide fast query processing and high throughput, making it ideal for applications that require real-time data processing and analysis. It also includes support for a range of different storage engines, including InnoDB, MyISAM, and Aria, giving developers greater flexibility when designing their applications.
The high degree of stability and scalability that MariaDB possesses is another essential quality of this database management system. It is equipped with sophisticated replication tools that enable data to be duplicated across numerous servers, ensuring that applications continue to be accessible even in the event that a server fails. In addition to that, it has support for clustering and sharding, both of which make it possible for applications to extend horizontally over numerous servers as the demand for them increases.
INSTALLING MARIADB IN STEP 1
As of this writing, Debian 11’s default software repository offers MariaDB version 10.5.15. It is the default MySQL variant according to the Debian MySQL/MariaDB packaging team.
Update your server’s package index with apt to install it:
sudo apt update
Install the package after that:
sudo apt install mariadb-server
These scripts will install MariaDB, but until they are finished, they will not ask you to modify any configuration settings or select a password. Because MariaDB is installed with an insecure default configuration by default, you will need to utilize a script that is included in the mariadb-server package in order to limit access to the server and delete accounts that are no longer being used.
MARIADB SETUP, PHASE 2
After a brand new MariaDB installation has been completed, the following step is to run the security script that was provided. This script adjusts a number of the default settings, some of which are less secure than others. These include sample users and remote root logins.
Activate the security script by doing the following:
sudo mysql_secure_installation
You will be led through a series of prompts that will allow you to alter the security settings for your MariaDB installation as this is done. At the very beginning, you will be required to provide the current database root password that you have access to. Because you have not yet created any, you should press ENTER to indicate “none” in this box.
The Output
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
We will need the current password for the root user in order to get into MariaDB and begin the process of securing it. If this is your first time installing MariaDB and you haven’t changed the root password yet, all you need to do is press the enter key here.
Enter the password that is currently being used for root, or press enter to use none.
You will be offered to switch to unix socket authentication if that is something you wish to do. You do not need to complete this step since you already own a secure root account. After inputting n, press ENTER.
The Output
If you want to make any changes to the root password, you will first need to answer to the notification that is displayed below. It is strongly recommended that the default authentication procedures for the root account in MariaDB on Debian 11 not be modified. This is because of the tight link that it has with the system maintenance activities that are carried out automatically on the system.
If access was denied to the administrator user, a database update might become corrupted. This could happen if the user had administrative privileges. After inputting n, press ENTER.
The Final Product
A new root password has been set? [Y/n]
If socket authentication does not function well for the requirements of your specific use case, you will ultimately learn how to create a second administrator account that needs a password in order to obtain access to the system.
After that, you will have the option to accept the default answers to any additional questions by clicking the Y key on your computer, followed by the Enter key. This will result in some anonymous users and the test database being deleted, an end being placed to remote root logins, the new rules being loaded, and MariaDB immediately beginning to utilize the alterations you made.
You have completed successfully setting up the initial security setup for MariaDB at this point. The following step is totally optional; nevertheless, you will need to do it if you would want to log in to your MariaDB server using a password instead of your username and the default password.
STEP 3
In the third stage, an administrator account may be created with or without a password. At this point, you must create an account with administrator privileges.
MariaDB 10.5 installations that are based on Debian come with a default configuration that enables the root MariaDB user to log in without a password by making use of the unix socket plugin. This is possible for installations of MariaDB 10.5 that are based on Debian. Despite the fact that this enhances security and usability in many instances, it may make things more difficult when you need to offer administrator access to an external program like phpMyAdmin. This is the case even if this improves security and usability in many contexts.
It is highly suggested that you do not make any modifications to the credentials that are associated with the root account at any time. This is owing to the fact that the server depends on the login details for the root account in order to perform tasks such as rotating the logs and starting and stopping the server. It is possible that changing the password that is stored in the configuration file that can be found at /etc/mysql/debian.cnf will initially be successful. However, further package updates could cause the alterations to be overwritten. The people who are responsible for maintaining the program do not recommend that you make any modifications to the root user account in any way. They suggest that as an alternative, a new administrator account that is guarded by a password should be created.
In order to accomplish this goal, a completely fresh account with the name admin will be created. This account will be given the same rights as the root account, but authentication for it will need the use of a password instead of a username. Enter the following commands on your terminal to bring up the MariaDB prompt:
sudo mariadb
Create a new user and grant them root access and password-based access. Make sure the username and password are updated to reflect your preferences:
MariaDB [(none)]>GRANT ALL ON *.* TO ‘admin’@’localhost’ IDENTIFIED BY ‘password’ WITH GRANT OPTION;
To make sure that the privileges are saved and accessible for the current session, flush them:
MariaDB [(none)]> FLUSH PRIVILEGES;
After that, close the MariaDB shell:
MariaDB [(none)]> exit
Let’s test the MariaDB installation lastly.
Fourth Step: Analyze MariaDB
When MariaDB is installed via the default repositories, it will run immediately once the installation has been completed. Confirm this by checking the current state of it.
sudo systemctl status mariadb
You’ll get output that looks somewhat like this:
The Output
- mariadb.service – MariaDB 10.5.15 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2022-03-11 22:01:33 UTC; 14min ago
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
. . .
If MariaDB is not currently operating, you may start it by typing the command sudo systemctl start mariadb into the terminal.
Using the mysqladmin tool, which is a client that gives you the opportunity to carry out administrative tasks, you may try to establish a connection to the database as an additional check. This can be done with the help of the mysqldimg utility. For instance, the sentence below instructs the Unix socket to connect to MariaDB using the root user and return the version:
sudo mysqladmin version
You will see results that resemble this:
sudo mysqladmin version
CONCLUSION
You installed the MariaDB relational database management system and secured it by using the mysql secure installation script that was deployed with it. This article will provide you with step-by-step instructions. You also had the ability, before you started evaluating the operation of the MariaDB server, to establish a new administrator user for the database management system and give them a password for authentication reasons. This was something you could do before you started testing the server’s functioning.
