Install MariaDB 10.4 on Ubuntu 18.04/Debian 9

1
979

This guide demonstrates how to install MariaDB 10.4 on Ubuntu 18.04/Debian 9. MariaDB 10.4.6 is the latest stable release as of this writing.

MariaDB 10.4 has come with a whole lot changes and improvements.

Install MariaDB 10.4 on Ubuntu 18.04/Debian 9

To install MariaDB 10.4, we are going to use MariaDB APT repo. This repo is not available by default on Ubuntu 18.04 systems. Hence, you need to create it.

Update and upgrade your system packages.

apt update
apt upgrade

Create MariaDB APT Repo

To create MariaDB APT repo, you can use the add-apt-repository command. However, this command is not available by default and ence, you need to first install the software-properties-common.

apt install software-properties-common

Import MariaDB APT Repo GPG Signing Key

Note that on Debian 9, you need to install the dirmngr package before you can import the GPG public key. dirmngr is used for managing and downloading OpenPGP and X.509 certificates.

apt install dirmngr

Next, run the command below to import MariaDB APT repo GPG signing key.

sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8

On Ubuntu 18.04, you can now create MariaDB 10.4 repo as shown below.

sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://sfo1.mirrors.digitalocean.com/mariadb/repo/10.4/ubuntu bionic main'

On Debian 9, you can create MariaDB 10.4 repo by running the command below;

sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://mirror.zol.co.zw/mariadb/repo/10.4/debian stretch main'

Run System Update

Before you can install MariaDB 10.4, update the system package cache by executing the following command:

apt update
apt upgrade

Install MariaDB 10.4 on Ubuntu 18.04/Debian 9

To install MariaDB 10.4 server and client, run the command below;

apt install mariadb-server mariadb-client

Running MariaDB 10.4

After installation, MariaDB started by default. It is also set to run on system boot by default.

systemctl status mariadb.service
● mariadb.service - MariaDB 10.4.6 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 Sat 2019-07-06 11:41:39 EAT; 41s ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
 Main PID: 11660 (mysqld)
   Status: "Taking your SQL requests now..."
    Tasks: 32 (limit: 2340)
   CGroup: /system.slice/mariadb.service
           └─11660 /usr/sbin/mysqld
systemctl is-enabled mariadb.service
enabled

MariaDB 10.4 Authentication

MariaDB 10.4 comes with a lot of security changes with the [email protected] user account being secured by default. The fact that you were supposed to set and remember the password of MariaDB server root user password no longer exists.

The [email protected] user created with the ability to either use;

  • the unix_socket authentication plugin. This allows the the [email protected] user to login without a password via the local Unix socket as long as the login is attempted from a process owned by the operating system root user account.
  • use the mysql_native_password authentication plugin if unix_socket authentication plugin fails. An invalid password is however initially set and thus, you need to set the password with the usual SET PASSWORD statement before this method can work.

As a result, you can simply login to MariaDB 10.4 by just using mysql or mysql -u root.

mysql -u root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 50
Server version: 10.4.6-MariaDB-1:10.4.6+maria~bionic-log 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)]>

To enable Password authentication for [email protected] user account, simply run the MariaDB initial security script and switch to unix_socket authentication.

mysql_secure_installation
...
Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] y
Enabled successfully!
Reloading privilege tables..
 ... Success!
...

Next,  revert to the old mysql_native_password authentication method for the user account by executing the following:

mysql -u root
ALTER USER [email protected] IDENTIFIED VIA mysql_native_password USING PASSWORD("[email protected]");

Login to MariaDB now requires password.

Read more about MariaDB 10.4 authentications here.

Well, that is on how to install MariaDB 10.4 on Ubuntu 18.04/Debian 9.

You can check our related tutorials by following the links below;

Install MySQL 8 on FreeBSD 12

Install MySQL 8 on Debian 9

Install MySQL 8 on Fedora 30/Fedora 29

Install LEMP Stack with MySQL 8 on Fedora 30/Fedora 29

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here