How to Install MariaDB 10 on Debian 10 Buster

Introduction

Here in this tutorial we will learn how to install MariaDB 10 on Debian 10 Buster operating system. However, MariaDB Database Server was formerly known as MySQL Database Server. Moreover, it is currently among one of the most popular database servers. MariaDB Database Server is free and open source relational database server. As we know that, MariaDB Server is developed by the same team of developers who were earlier involved in the development of MySQL Database Server. In addition to above, the MariaDB Database Server is guaranteed to always stay open source in the future. Also, MariaDB Database Server is part of the default packaging of most of the Debian and Debian 10 based Linux distributions. Additionally, MariaDB Database Server is a relational database management system.

Link to the Official Website of MariaDB Database Server

However, MariaDB Database Server is the most suitable alternative to MySQL Database Server. In addition to the above, it is also a part of the most popular LAMP Server comprising Linux Operating System, Apache Web Server, MariaDB Database Server and the programming language as PHP, Python or Perl.

Moreover, here, in this guide we will learn how to install MariaDB 10 database server on Debian 10 Server or Desktop operating system.

Link to the Official Website of Debian 10 Buster Operating System

Even though, MariaDB Database Server and Client system is a part of the packaging of most of the Debian and Debian 10 based Linux distributions. However, this installation procedure will be same for the other similar debian based distributions.

Prerequisites for Installation of MariaDB 10 on Debian 10

As a matter of fact, to best use this tutorial, we will need a Debian 10 Server or Desktop operating system installed on our machine. Further, this Debian 10 operating System must have a root user and UFW firewall configured. Also, we can setup this by using our Debian 10 operating system setup guide. However, if you want to learn how to install Debian 10 desktop operating system on your computer. Then you can follow the link to our Debian 10 operating system setup guide. The link  is given below:

How to Install Debian 10 Buster

Installation Procedure of MariaDB 10 on Debian 10

Furthermore, here, we will describe the installation procedure in steps.

Step 1. Not to mention, the first step is to update the operating system’s package index using the apt update command.

sudo apt-get update

Step 2. Further, in the following step we will install the MariaDB Database Server and MariaDB Database Client packages. However, for this, we will use the same apt-get command of Debian 10 Operating System. Also, this command will also pull the other dependency packages along with the database server and client packages. The following command will install the MariaDB Database Server and Client without any prompt. It will also set a blank password for the root user. It will also install and configure a test database along with system database.  As a matter of fact, this installation will leave the default MariaDB database insecure.

sudo apt-get install mariadb-server mariadb-client

Configure and Secure MariaDB Database Server

However, after the installation of MariaDB Server and Client is complete. Further, we will run mysql_secure_installation script. Moreover, this script will be used to set the database root user password. It will also remove test database and remove anonymous users . And finally flush privileges. However, by using this script we will be able to restrict the access to the database. In addition to above, we will be able to secure our database server installation.

sudo mysql_secure_installation

Furthermore, the above script will prompt us a series of questions. Additionally, through our responses to these questions we will be able to change and make secure our MariaDB database server default installation.

However, the first prompt will be to enter the existing password of the MariaDB root User. Moreover, if this is a fresh installation of the MariaDB Database Server, the root user’s password will be blank. Therefore, we have to just press the enter key in response to the current password query. Furthermore, below given are the full text of prompts for mysql_secure_installation script and the responses to be given.

sudo mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we’ll need the current
password for the root user.  If you’ve just installed MariaDB, and
you haven’t set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on…
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorization.
Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
… Success!

Remove Anonymous User

However, by default, a MariaDB Server installation has an anonymous user, allowing anyone to log into MariaDB Server without having to have a user account created for them.  Moreover, this is intended only for testing, and to make the installation go a bit smoother.  Certainly, you should remove them before moving into a production environment.

However, the option is – Remove anonymous users? [Y/n] Y … Success!

Disallow Root Login Remotely

As a matter of fact, root should only be allowed to connect from ‘localhost’.  Finally, this ensures that someone cannot guess at the root password from the network.

However, this is achieved through the option – Disallow root login remotely? [Y/n] Y … Success!

Remove Test Database

However, by default, MariaDB comes with a database named ‘test’ that anyone can access.  However, this is also intended only for testing. Moreover, it should be removed before moving into a production environment. Finally, this is done through the Option –

Remove test database and access to it? [Y/n] Y – Dropping test database… … Success!

Removing privileges on test database… … Success!

Reload Privileges

Finally, reloading the privilege tables will ensure that all changes made so far will take effect immediately.

However, this is done in the step – Reload privilege tables now? [Y/n] Y … Success! Cleaning up… All done! 

Moreover, if you’ve completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!

How to Change the Password Authentication Method in MariaDB

By default, MariaDB Server uses the UNIX socket plug-in to authenticate users.

Further, we will set the password authentication method in MariaDB Server to native. Later on, when we will install phpMyAdmin, this will enable us to connect as root user. The next step is to  login in to the newly installed MariaDB Database Server as root user. Then, issue the following command in the terminal window step by step in the given order.

sudo mysql -u root -p
Enter password:                                 [Enter root User Password]

Additionally, the output of the above command will be similar to the shown below and we will get the MariaDB command prompt.

Welcome to the MariaDB monitor.  Commands end with; or \g.
Your MariaDB connection id is 58
Server version: 10.3.29-MariaDB-0+deb10u1 Debian 10
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)]>

Additionally, run the given below SQL statement on the MariaDB Command Prompt.

update mysql.user set plugin = 'mysql_native_password' where User = 'root';

However, the output of the above command will be similar to the shown below.

Query OK, 1 row affected (0.000 sec)
Rows matched: 1  Changed: 1  Warnings: 0

Additionally, run the given below SQL statement on the MariaDB Command Prompt.

flush privileges;

However, the output of  the above command will be similar to the given below.

Query OK, 0 rows affected (0.000 sec)

Finally quit MariaDB by issuing quit command on the MariaDB prompt.

quit
Bye

However, quit the MariaDB Database Server Command prompt by issuing the “quit” command. Finally, the installation part is complete.

Testing Newly Installed MariaDB Server

Furthermore, this is the time for testing the newly installed MariaDB Database Server.

Moreover, this is the time to test the MariaDB database Server installation. Further, run the following command in the terminal window.

sudo systemctl status mariadb

Furthermore, the output of the command will be similar to given below.

sudo systemctl status mariadb
mariadb.service – MariaDB 10.3.29 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2021-08-02 09:59:11 IST; 18min ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 3406 (mysqld)
Status: “Taking your SQL requests now…”
Tasks: 30 (limit: 4669)
Memory: 78.4M
CGroup: /system.slice/mariadb.service
└─3406 /usr/sbin/mysqld
Aug 02 09:59:12 smtp /etc/mysql/debian-start[3444]: Phase 6/7: Checking and upgrading tables
Aug 02 09:59:12 smtp /etc/mysql/debian-start[3444]: Running ‘mysqlcheck’ with connection arguments: –
Aug 02 09:59:12 smtp /etc/mysql/debian-start[3444]: # Connecting to localhost…
Aug 02 09:59:12 smtp /etc/mysql/debian-start[3444]: # Disconnecting from localhost…
Aug 02 09:59:12 smtp /etc/mysql/debian-start[3444]: Processing databases
Aug 02 09:59:12 smtp /etc/mysql/debian-start[3444]: information_schema
Aug 02 09:59:12 smtp /etc/mysql/debian-start[3444]: performance_schema
Aug 02 09:59:12 smtp /etc/mysql/debian-start[3444]: Phase 7/7: Running ‘FLUSH PRIVILEGES’
Aug 02 09:59:12 smtp /etc/mysql/debian-start[3444]: OK
Aug 02 09:59:12 smtp /etc/mysql/debian-start[3499]: Triggering myisam-recover for all MyISAM tables a
lines 1-22/22 (END)

How to Start, Stop and Restart MariaDB Database Server

However, to start, stop and restart MariaDB Database Server run the following command in the terminal as root.

sudo systemctl start mariadb
sudo systemctl stop mariadb
sudo systemctl restart mariadb

That’s all; now, we have successfully installed and configured the MariaDB Database Server and Client on Debian 10 Buster. Finally,  now we can start using it.

Leave a Reply

Your email address will not be published.