How To Install MariaDB 10.9 on Ubuntu 20.04

In this guide, we want to teach you How To Install MariaDB 10.9 on Ubuntu 20.04.

MariaDB is an open-source relational database management system. As with other relational databases, MariaDB stores data in tables made up of rows and columns. Users can define, manipulate, control, and query data using Structured Query Language, more commonly known as SQL.

Steps To Install MariaDB 10.9 on Ubuntu 20.04

To install MariaDB 10.9, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide the Initial Server Setup with Ubuntu 20.04.

Now follow the steps below to complete this guide.

Set up MariaDB 10.9 on Ubuntu 20.04

First, you need to install the required packages and dependencies on your server with the following command:

sudo apt-get install curl software-properties-common dirmngr ca-certificates apt-transport-https -y

Import MariaDB 10.9 GPG Key & Repository

At this point, you need to import the MariaDB 10.9 GPG key and Repository by using the following command:

curl -LsS | sudo bash -s -- --mariadb-server-version=10.9

In your output you will see:

# [info] Checking for script prerequisites.
# [info] MariaDB Server version 10.9 is valid
# [info] Repository file successfully written to /etc/apt/sources.list.d/mariadb.list
# [info] Adding trusted package signing keys...
# [info] Running apt-get update...
# [info] Done adding trusted package signing keys

Then, update your local package index with the following command:

sudo apt update

Installing MariaDB 10.9

To install MariaDB, you must install the client and the server packages. To do this, run the command below:

sudo apt install mariadb-server mariadb-client -y

Verify your MariaDB installation by checking its version:

mariadb --version
mariadb Ver 15.1 Distrib 10.9.2-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

MariaDB will start automatically on your server. To check that it is active and running on your server, run the following command:

sudo systemctl status mariadb
● mariadb.service - MariaDB 10.9.2 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor prese>
Drop-In: /etc/systemd/system/mariadb.service.d
Active: active (running) since Mon 2022-09-12 11:35:01 CEST; 1min 13s ago
Docs: man:mariadbd(8)
Main PID: 9381 (mariadbd)
Status: "Taking your SQL requests now…"
Tasks: 10 (limit: 2282)
Memory: 78.9M
CGroup: /system.slice/mariadb.service
└─9381 /usr/sbin/mariadbd

Also, you can enable your MariaDB service to start on boot:

sudo systemctl enable mariadb

Run MariaDB Secure Installation Script

At this point, you can secure your MariaDB 10.9 installation on Ubuntu 20.04 by running a security script.

To do this, use the following command:

sudo mysql_secure_installation

You will be asked to set a root password for your MariaDB and from there enter yes to answer other questions.

Now you can access your MariaDB shell with the command below:

sudo mysql -u root -p

Enter your root password and press enter.

Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 39
Server version: 10.9.2-MariaDB-1:10.9.2+maria~ubu2004 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)]>

Remove MariaDB 10.9 from Ubuntu 20.04

If you no longer wish to use MariaDB and want to remove it in full, execute the following command:

sudo apt autoremove mariadb-server mariadb-client --purge -y

Note, this will remove MariaDB completely including all database data.

To remove the bash script repository, use the following command.

# sudo rm /etc/apt/sources.list.d/mariadb.list
# sudo apt update

For more information, you can visit the MariaDB Documentation Page.


At this point, you learn to Install MariaDB 10.9 on Ubuntu 20.04.

Hope you enjoy it.

You may be interested in these articles:

Install Varnish Cache with Apache on Ubuntu 20.04

How To Set up XWiki on Ubuntu 20.04

Install and Configure Memcached on Ubuntu 20.04

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!