Tutorial MariaDB installation on Debian 10

Tutorial MariaDB installation on Debian 10

As you already learned about MariaDB in recent articles, We are going to present the tutorial MariaDB installation on Debian 10. To introduce MariaDB, the one of the most popular open-source database management system, we can say it is a common alternative used for the MySQL portion of the popular LAMP (Linux, Apache, MySQL, PHP/Python/Perl) stack. And part of most cloud offerings and the default in most Linux distributions. You should receive the compatible MariaDB replacement versions instead, If you attempt to install MySQL server related packages.


We will review the following steps until the installation guide finish.

  • Update your package index using apt
  • Install the mariadb-server package using apt. The package also pulls in related tools to interact with MariaDB
  • Run the included mysql_secure_installation security script to restrict access to the server



The tutorial may be more useful if you know:

Recommended Article: How to Copy a File on a Nano Server with PowerShell

Tutorial MariaDB installation on Debian 10

1- Installing MariaDB

Update the package index on your server with apt to install it

sudo apt update  

To install the package:

sudo apt install mariadb-server      

2- Configuring MariaDB

Run the security script:

sudo mysql_secure_installation  

After this, you may face a series of prompts to make some changes to your MariaDB installation’s security options. When you are prompted to enter the current database root password therefore press ENTER to indicate “none”.

The next prompt is about to set up a database root password. Type N and then press ENTER. In Debian, the root account for MariaDB is tied closely to automated system maintenance.

To accept the defaults for all the subsequent questions, you can press Y and then ENTER, to remove some anonymous users and the test database, disable remote root logins.


Buy Linux Virtual Private Server


3- Adjusting User Authentication and Privileges

You should create a new account named admin with the same capabilities as the root account, but configured for password authentication. In other words, open up the MariaDB prompt from your terminal run the following.

sudo mysql  

To create a new user with root privileges and password-based access, change the username and password to match your preferences.

MariaDB [(none)]> GRANT ALL ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;  

You can flush the privileges to ensure that they are saved and available in the current session.

MariaDB [(none)]> FLUSH PRIVILEGES;  

Now you can exit the MariaDB shell:

MariaDB [(none)]> exit  


4- Testing MariaDB

After installation after default repositories, MariaDB should start running automatically. Use the command below to test it.

sudo systemctl status mariadb  

The output will display as below.

mariadb.service - MariaDB 10.3.15 database server     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)     Active: active (running) since Fri 2019-07-12 20:35:29 UTC; 47min ago       Docs: man:mysqld(8)      Main PID: 2036 (mysqld)     Status: "Taking your SQL requests now..."      Tasks: 30 (limit: 2378)     Memory: 76.1M     CGroup: /system.slice/mariadb.service             └─2036 /usr/sbin/mysqld    Jul 12 20:35:29 deb-mariadb1 /etc/mysql/debian-start[2074]: Phase 6/7: Checking and upgrading tables  Jul 12 20:35:29 deb-mariadb1 /etc/mysql/debian-start[2074]: Running 'mysqlcheck' with connection arguments: --socket='/var/run/mysqld/mysqld.sock' --host='localhost' --socket='/var/run/mysqld/mysqld.sock' --host='localhost' --socket='/var/run/mysqld/mysqld.sock'  Jul 12 20:35:29 deb-mariadb1 /etc/mysql/debian-start[2074]: # Connecting to localhost...  Jul 12 20:35:29 deb-mariadb1 /etc/mysql/debian-start[2074]: # Disconnecting from localhost...  Jul 12 20:35:29 deb-mariadb1 /etc/mysql/debian-start[2074]: Processing databases  Jul 12 20:35:29 deb-mariadb1 /etc/mysql/debian-start[2074]: information_schema  Jul 12 20:35:29 deb-mariadb1 /etc/mysql/debian-start[2074]: performance_schema  Jul 12 20:35:29 deb-mariadb1 /etc/mysql/debian-start[2074]: Phase 7/7: Running 'FLUSH PRIVILEGES'  Jul 12 20:35:29 deb-mariadb1 /etc/mysql/debian-start[2074]: OK  Jul 12 20:35:30 deb-mariadb1 /etc/mysql/debian-start[2132]: Triggering myisam-recover for all MyISAM tables and aria-recover for all Aria tables


You can start the MariaDB after running with the sudo systemctl start mariadb command, but to check more, try connecting to the database using the mysqladmin tool. In addition, for example, the below command means to connect to MariaDB as root. And return the version using the Unix socket:

sudo mysqladmin version  

An output similar to below should be displayed.

mysqladmin  Ver 9.1 Distrib 10.3.15-MariaDB, for debian-linux-gnu on x86_64  Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.    Server version      10.3.15-MariaDB-1  Protocol version    10  Connection      Localhost via UNIX socket  UNIX socket     /var/run/mysqld/mysqld.sock  Uptime:         48 min 14 sec    Threads: 7  Questions: 474  Slow queries: 0  Opens: 177  Flush tables: 1  Open tables: 31  Queries per second avg: 0.163

In case of configuration a separate administrative user with password authentication. After that, perform the same operation by running the below command.

mysqladmin -u admin -p version  

In conclusion, MariaDB is up and running and that your user is able to authenticate successfully now.


Dear user, we hope you would enjoy this tutorial, you can ask questions about this training in the comments section, or to solve other problems in the field of Eldernode training, refer to the Ask page section and raise your problems in it.


Suggested to read

Tutorial Mariadb installation on Ubuntu

Initial Setup with Debian 10

We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave Your Comment

Your email address will not be published.

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way


7 days a week, 24 hours a day