Install MariaDB 10.6 on Ubuntu 20.04

MariaDB Server is a cross-platform relational database that enables to access data using SQL language. It is a fork of MySQL Server. Development of MariaDB was started from the original repository of MySQL. MariaDB might be drop-in replacement for MySQL. MariaDB is an open-source project which released under the GPLv2 license.

This tutorial explains how to install MariaDB 10.6 on Ubuntu 20.04.

Install MariaDB

Download bash script that adds and configures the MariaDB repository:


Assign an execute permission to script:

chmod a+x mariadb_repo_setup

Run script:

sudo ./mariadb_repo_setup --mariadb-server-version="mariadb-10.6"

Remove script because no longer needed it:

rm -rf mariadb_repo_setup

Execute the following command to install MariaDB 10.6:

sudo apt install -y mariadb-server

When it finished, we can check MariaDB version:

mariadb --version

We can use the following command to check if MariaDB service is running:

sudo service mariadb status

We can also stop, start and restart the service:

sudo service mariadb stop
sudo service mariadb start
sudo service mariadb restart

By default, password for the root user is blank and we can connect to the server without any authentication:

sudo mariadb -u root

Execute the following SQL statement to change password of root user:

ALTER USER root@localhost IDENTIFIED BY 'pwd123';

Exit interactive mode by running exit command inside the client:


Now try to connect to server using password:

mariadb -u root -p

Uninstall MariaDB

Run the following command if you want to completely remove any package with a name that starts with mariadb and anything related to it:

sudo DEBIAN_FRONTEND=noninteractive apt purge --autoremove -y mariadb*

Remove GPG key and repository:

sudo rm -rf /etc/apt/trusted.gpg.d/mariadb-keyring-2019.gpg
sudo rm -rf /etc/apt/sources.list.d/mariadb.list

Remove MySQL user:

sudo deluser mysql

You can also remove MySQL configuration, data, and other related directories and files:

sudo rm -rf /etc/mysql
sudo rm -rf /var/lib/mysql
sudo rm -rf /usr/share/mysql
sudo rm -rf /etc/systemd/system/mariadb.service.d
sudo rm -rf /etc/apt/preferences.d/mariadb-enterprise.pref
sudo rm -rf /root/.mysql_history
rm -rf ~/.mysql_history

Leave a Comment

Your email address will not be published. Required fields are marked *