How To Install MariaDB on Debian 10

Prerequisites

https://wiki.crowncloud.net/?Prerequisites_for_Debian10

Installing MariaDB

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

 sudo apt update

Output:

[email protected]:~# sudo 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.

sudo apt install mariadb-server

output:

[email protected]:~# sudo apt install mariadb-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:

Configuring MariaDB

sudo mysql_secure_installation

Adjusting User Authentication and Privileges

sudo mysql

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

MariaDB [(none)]> 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

sudo systemctl status mariadb

Output:

[email protected]:~# 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:

[email protected]:~# 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:

[email protected]:~# 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