Home MySQL How to Install MariaDB in Ubuntu 20.04/22.04

How to Install MariaDB in Ubuntu 20.04/22.04

MariaDB has earned its stripes as a reputable database management system due to its feature-rich and performant nature. It being a MySQL fork implies that MariaDB offers similar features and performance metrics with the advantage of being free and completely open-source.

Therefore, for users that are invested in web-based or desktop-based application development projects, the input that mariaDB brings to the table cannot be ignored.


Be a root/sudoer user on the Ubuntu system you wish to install MariaDB database management software.

Installing MariaDB in Ubuntu

An updated system is a performant system, make sure your Ubuntu system is up-to-date with the latest software.

$ sudo apt update && sudo apt upgrade -y 

Once your Ubuntu system is up-to-date, we can proceed and install MariaDB.

$ sudo apt install mariadb-server -y 
Install MariaDB in Ubuntu
Install MariaDB in Ubuntu

The installation process should take a minute or two to complete due to MariaDB’s light nature. Next, confirm the installed version of MariaDB on your Ubuntu system.

$ mariadb --version 
Check MariaDB Version
Check MariaDB Version

At this point, this article assumes you intend to use MariaDB as your primary database management software. We need to start and enable it so that it keeps on running even after the Ubuntu system shutdown or reboot.

$ sudo systemctl start mariadb 
$ sudo systemctl enable mariadb 
$ sudo systemctl status mariadb 
Check MariaDB Status in Ubuntu
Check MariaDB Status in Ubuntu

Securing MariaDB in Ubuntu

The following MariaDB pre-configuration security script ensures that set the root database user password and other warranted database configurations like removing anonymous users, disallowing remote login, removing test databases, before you can start using it.

$ sudo mysql_secure_installation
Secure MariaDB in Ubuntu
Secure MariaDB in Ubuntu

Next, you need to log in to your database to test MariaDB.

$ sudo mysql -u root -p 

Create a database user, database, and assign control over the created database to the user.

MariaDB [(none)]> CREATE USER linuxshelltips@localhost IDENTIFIED BY "Your_preferred_db_user_password";
MariaDB [(none)]> CREATE DATABASE linuxshelltips_db;
MariaDB [(none)]> GRANT ALL ON linuxshelltips_db.* TO linuxshelltips@localhost; 
MariaDB [(none)]> exit
Create MySQL Database User in Ubuntu
Create MySQL Database User in Ubuntu

This article has walked us through installing, securing, and testing MariaDB database management software on the Ubuntu system.

Ravi Saive
I am an Experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies. Founder of TecMint.com, LinuxShellTips.com, and Fossmint.com. Over 150+ million people visited my websites.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

Got something to say? Join the discussion.

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.