How To Install MariaDB on Debian 10

MariaDB is a community-developed, commercially supported fork of the MySQL relational database management system, intended to remain free and open-source software under the GNU General Public License.

Installing MariaDB

To install it, update the package index on your server with apt:

apt update

Output:

root@vps:~# apt update
Hit:1 http://security.debian.org/debian-security buster/updates InRelease
Hit:2 http://deb.debian.org/debian buster InRelease
Get:3 http://deb.debian.org/debian buster-updates InRelease [46.8 kB]
Fetched 46.8 kB in 1s (83.5 kB/s)
Reading package lists... Done

Install mariadb server.

apt install mariadb-server

Output:

root@vps:~# apt install mariadb-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:

Configuring MariaDB

mysql_secure_installation

Adjusting User Authentication and Privileges

mysql -u root -p

Create a new user with root privileges and password-based access.

GRANT ALL ON *.* to 'admin'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;

Output:

MariaDB [(none)]> GRANT ALL ON *.* to 'admin'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;          
Query OK, 0 rows affected (0.005 sec)

Flush the privileges to ensure that they are saved and available in the current session:

FLUSH PRIVILEGES;

Exit the MariaDB shell:

exit;

Testing MariaDB

systemctl status mariadb

Output:

root@vps:~# systemctl status mariadb.service
● mariadb.service - MariaDB 10.3.15 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset:
Active: active (running) since Sat 2019-07-27 12:54:28 EDT; 24min ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 2743 (mysqld)

For an additional check, you can try connecting to the database using the mysqladmin tool, which is a client that lets you run administrative commands.

sudo mysqladmin version

Output:

root@vps:~# sudo mysqladmin version
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:                 27 min 49 sec

If you configured a separate administrative user with password authentication, you could perform the same operation by typing:

mysqladmin -u admin -p version

Output:

root@vps:~# mysqladmin -u admin -p version
Enter password:
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:                 30 min 42 sec