MariaDB is a free and open-source relational database management system (RDBMS) that is a fork of the popular MySQL database system. In this article, we will explain how to install MariaDB on a system running the Debian 11 operating system.
Before we begin, there are a few prerequisites that need to be met. First, you must have a system running Debian 11, and it should be connected to the internet. You will also need to have administrative privileges on the system, as the installation process requires access to the root user account or a user account with sudo privileges.
To start, let’s update the package manager index and upgrade any existing packages to their latest versions. This is important because it ensures that we have the latest security patches and bug fixes, as well as the latest versions of the packages we will be installing. Run the following command to update the package manager index:
sudo apt update
Next, run the following command to upgrade any existing packages to their latest versions:
sudo apt upgrade
Once the package manager index has been updated and any existing packages have been upgraded, we can proceed with the installation of MariaDB. To do this, we will use the apt package manager.
First, run the following command to install the MariaDB server and client packages:
sudo apt install mariadb-server mariadb-client
This will install the MariaDB server and client packages, along with any required dependencies. Once the installation is complete, the MariaDB service will be automatically started.
To verify that the MariaDB service is running, you can run the following command:
systemctl status mariadb
This command should output the status of the MariaDB service, along with any relevant information. If the service is running, you will see a message that says “active (running)”.
Now that the MariaDB service is running, we can proceed with the configuration of the database system. The first step is to run the MariaDB security script, which will guide you through the process of setting a password for the root user and removing any insecure default settings.
To run the MariaDB security script, run the following command:
sudo mysql_secure_installation
This will start the MariaDB security script. It will prompt you for the current root password, which is empty by default. Since you have not set a password for the root user yet, simply press Enter to continue.
Next, the script will ask you if you want to set a password for the root user. Type “Y
” and press Enter to do this. The script will then prompt you to enter and confirm your new password.
After setting the root password, the MariaDB security script will ask you if you want to remove anonymous users. These are users that do not have a username or password, and they are not recommended for security reasons. Type “Y
” and press Enter to remove anonymous users.
The script will also ask you if you want to disallow remote root login. This means that the root user will not be able to log in to the MariaDB server from a remote machine. This is recommended for security reasons. Type “Y
” and press Enter to disallow remote root login.
Finally, the script will ask you if you want to remove the test database. This database is used for testing purposes and is not needed in a production environment. Type “Y
” and press Enter to remove the test database.
Once the MariaDB security script has finished running, you can log in to the MariaDB server using the root user and the password you set. To do this, run the following command:
mysql -u root -p
This will prompt you for the root password. Enter your password and press Enter to log in to the MariaDB server.
Once you are logged in, you can create new databases, users, and tables, and perform other database management tasks. For more information on how to use the MariaDB server, refer to the MariaDB documentation.
That’s it! You have successfully installed and configured MariaDB on your system running Debian 11. You can now use MariaDB to store and manage your data.