MariaDB is a community fork of the MySQL relational database management system. It's freely available and open-source under the GNU General Public License.

MariaDB, in contrast to MySQL, offers high compatibility, supports PL/SQL, is faster in replication and querying, supports big data operations, allows seamless scaling, and offers numerous additional features.

You can consider replacing your existing MySQL with MariaDB, but first, make sure to check the differences among the versions to avoid disrupting the applications using the database server.

In this article, I'll show you how to install MariaDB on Ubuntu 24.04 (it'll also work for Ubuntu 23.04 and 22.04) with practical examples.

How to Install MariaDB on Ubuntu 24.04

The installation and configuration of MariaDB involve multiple steps, so open your terminal and follow each step one by one.

Step 1: Update the Ubuntu System

The first step is to update the repository information and any pending updates on your Ubuntu system.

$ sudo apt update && sudo apt upgrade -y


updating ubuntu

Step 2: Install the MariaDB Server

Next, install the MariaDB server using the following command:

$ sudo apt install mariadb-server


install mariadb on ubuntu

Step 3: Check that the MariaDB Service is Running

MariaDB creates a Systemd service named mariadb for easier management after installation. Therefore, make sure the MariaDB service is operational by running the following command:

$ sudo systemctl status mariadb


check mariadb systemd service

It's running smoothly for me, but if it's not running on your system, then execute the following two commands:

# Make sure the MariaDB service will autostart on every system boot.
$ sudo systemctl enable mariadb
# Restart the MariaDB service for the current login session.
$ sudo systemctl restart mariadb

Step 4: Configure and Secure the MariaDB Server

Prior to actually using MariaDB, it's recommended to run a security script that comes bundled with the MariaDB package to enhance the security of your MariaDB server.

$ sudo mysql_secure_installation

The script will prompt you to configure some security settings for MariaDB, starting with setting a root password.

running installation script on ubuntu

Then it will prompt you to change the root password, which you can skip since you've already entered it previously, and confirm the removal of anonymous users and remote root login.

removing anonymous users and disabling remote root login in mariadb

Lastly, confirm the removal of the test user and refresh the privileges table to apply the changes.

removing test user and reloading privileges table in mariadb

Step 5: Log into the MariaDB Console

Now that the installation and configuration of MariaDB are complete, you can access the MariaDB console using any of the following commands:

$ sudo mariadb


$ mariadb -u root -p


mariadb console

How to Upgrade MariaDB on Ubuntu 24.04

The MariaDB package will update automatically during the system update, or you can manually initiate the MariaDB update using the following command:

$ sudo mariadb-upgrade


update mariadb on ubuntu

How to Remove MariaDB on Ubuntu 24.04

If you want to remove MariaDB from Ubuntu in the future, you can simply execute the following two commands:

$ sudo apt remove --purge mariadb-server mariadb-client
$ sudo apt autoremove


removing mariadb from ubuntu

Here comes the end of this article, so I hope you are easily able to install MariaDB on your Ubuntu system. If you have any questions, feel free to comment.