Follow through this guide to learn how to install MariaDB 10.5 on Debian 10 Buster. “MariaDB 10.5 is the current stable series of MariaDB. It is an evolution of MariaDB 10.4 with several entirely new features not found anywhere else and with backported and reimplemented features from MySQL”.
Installing MariaDB 10.5 on Debian 10 Buster
Run System Update
Assuming that you are installing MariaDB 10.5 on a newly installed Debian 10 buster, update and upgrade your system packages.
apt update
apt upgrade
There are two methods in which you can install MariaDB;
Install MariaDB 10.5 from APT Repository
MariaDB 10.3 is the currently available version on the default Debian 10 Buster repos;
apt show mariadb-server
Package: mariadb-server
Version: 1:10.3.23-0+deb10u1
Priority: optional
Section: database
Source: mariadb-10.3
Maintainer: Debian MySQL Maintainers <[email protected]>
Installed-Size: 67.6 kB
Depends: mariadb-server-10.3 (>= 1:10.3.23-0+deb10u1)
Homepage: https://mariadb.org/
Tag: devel::lang:c++, devel::lang:sql, devel::library, implemented-in::c++,
interface::commandline, interface::daemon, network::server
protocol::db:mysql, role::devel-lib, role::metapackage, role::program,
works-with::db
Download-Size: 31.0 kB
APT-Sources: http://deb.debian.org/debian buster/main amd64 Packages
Therefore, to install MariaDB 10.5, you need to install MariaDB 10.5 APT repos.
Install MariaDB 10.5 APT repos on Debian 10 Buster
Execute the commands below to install MariaDB 10.5 APT repos;
apt install software-properties-common dirmngr
apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
add-apt-repository 'deb [arch=amd64] http://mirrors.ukfast.co.uk/sites/mariadb/repo/10.5/debian buster main'
To choose your MariaDB mirrors, head over to MariaDB repositories site, choose your Linux distro, distro release, MariaDB version to install and finally the Mirrors to use.
Resynchronize your package cache;
apt update
Install MariaDB 10.5;
apt install mariadb-server
Install MariaDB 10.5 using .DEB Binary Files
While this is not the recommended way of installing MariaDB, you can as well download .deb binary files and install it. Follow the link below to learn how to install MariaDB using the .deb files.
Install MariaDB using deb binary files
Verify the MariaDB installed version.
mysql -V
mysql Ver 15.1 Distrib 10.5.5-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
Running MariaDB 10.5 on Debian 10 Buster
Upon installation, MariaDB is started and enabled to run on system boot;
systemctl status mariadb
● mariadb.service - MariaDB 10.5.5 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: active (running) since Mon 2020-08-24 17:02:06 EDT; 43min ago
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 3750 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 9 (limit: 1149)
Memory: 83.2M
CGroup: /system.slice/mariadb.service
└─3750 /usr/sbin/mariadbd
Aug 24 17:03:12 debian /etc/mysql/debian-start[3771]: information_schema
Aug 24 17:03:12 debian /etc/mysql/debian-start[3771]: mysql
Aug 24 17:03:12 debian /etc/mysql/debian-start[3771]: performance_schema
Aug 24 17:03:12 debian /etc/mysql/debian-start[3771]: Phase 6/7: Checking and upgrading tables
Aug 24 17:03:12 debian /etc/mysql/debian-start[3771]: Processing databases
Aug 24 17:03:12 debian /etc/mysql/debian-start[3771]: information_schema
Aug 24 17:03:12 debian /etc/mysql/debian-start[3771]: performance_schema
Aug 24 17:03:12 debian /etc/mysql/debian-start[3771]: Phase 7/7: Running 'FLUSH PRIVILEGES'
Aug 24 17:03:12 debian /etc/mysql/debian-start[3771]: OK
Aug 24 17:03:12 debian /etc/mysql/debian-start[4607]: Triggering myisam-recover for all MyISAM tables and aria-recover for all Aria tables
You can manage the service via systemctl command. For example, to stop MariaDB service;
systemctl restart mariadb
To stop the service;
systemctl stop mariadb
Disable the service from running on system boot;
systemctl disable mariadb
Securing MariaDB 10.5
MariaDB comes with a default security script, mysql_secure_installation
that is used to improve the security of MariaDB installation by:
- Setting the password for root accounts (if need be).
- Disabling remote root login to the databases.
- Removing anonymous-user accounts.
- Removing the test database, which by default can be accessed by anonymous users.
Simply run the command below to launch the script.
mysql_secure_installation
MariaDB Authentication
The new installations of MariaDB have two secure accounts are created during the installation. The accounts are root@localhost
and mysql@localhost
. Both accounts uses either of the unix_socket
and the mysql_native_password
authentication plugins.
unix_socket
authentication plugin allows a system root
user or a user with sudo rights
to login as root@locahost
to MariaDB database without a password.
With unix_socket
authentication plugin, while being a root user, you can simply login by running either of the commands below;
mysql
or
mysql -u root
Even if you run, mysql -u root -p
, and press ENTER for blank password, you will still login.
As a user with sudo rights, prefix the commands above with sudo
.
Enable MariaDB password Authentication
The mysql_native_password
plugin is used as a failover for the unix_socket
plugin. However, the account has an invalid password. To enable password authentication, you need to login to MariaDB as root user as shown above and set the password.
mysql
set password = password("P@sSw0Rd123");
flush privileges;
quit
This re-enables the MariaDB password authentication and hence, you can now login as non root or non sudo user.
koromicha@debian:~$ mysql -u root -p
Enter password: ENTER PASSWORD
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 39
Server version: 10.5.5-MariaDB-1:10.5.5+maria~buster mariadb.org binary distribution
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)]>
Similarly, you can login as mysql user;
sudo -u mysql mysql
Set Native Password Authentication Method as Default
To completely disable unix_socke
t authentication plugin and instead use the msqyl_native_password
authentication method, simply login to MariaDB and change the authentication plugin for root user.
mysql
ALTER USER root@localhost IDENTIFIED VIA mysql_native_password USING PASSWORD("MyPQQSSword");
flush privileges;
quit
Next time you try to login without specifying the password, login will fail.
sudo mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
You can check our other guides on MariaDB/MySQL installations by following the links below;
Install MariaDB 10 on Debian 10 Buster
Install MariaDB 10.4 on Ubuntu 18.04/Debian 9
Install MariaDB 10.3 on CentOS 7