Installing MariaDB on Ubuntu: 6 Easy Steps

By: Published: October 29, 2021

Feature Image - Installing MariaDB on Ubuntu

Today most organizations prefer MariaDB as their database system over MySQL not only because of the open-source nature but also because MariaDB has now become more efficient in case of complex queries.

In this article, we will be discussing two different ways of installing MariaDB on Ubuntu. The first method will describe how to install MariaDB in Ubuntu from Ubuntu repositories, while the second method will describe how to install MariaDB from the official MariaDB repositories. 

You can also check our article on Install MongoDB on Ubuntu.

Table of Contents

What is MariaDB?

MariaDB Logo - Installing MariaDB Ubuntu

MariaDB is a relational database management system. It was developed by the MariaDB foundation together with the original MySQL developers. It is considered a drop-in replacement for MySQL. MariaDB supports SQL, hence, you can use SQL queries to insert, manipulate, and retrieve data from MariaDB. MariaDB is mostly used as an alternative to MySQL. There are many similarities between the two database management systems (DBMSs). 

Official documentation of MariaDB can be found here.


  • Ubuntu 18.04 or above. 

Installing MariaDB on Ubuntu

Installing MariaDB from Ubuntu Repositories

To install MariaDB in Ubuntu from Ubuntu repositories, follow the steps given below:

Installing MariaDB on Ubuntu Step 1: Update the packages index. Simply run the following command from your Ubuntu terminal:

sudo apt update

After running the command, the packages will be up-to-date. 

Installing MariaDB on Ubuntu Step 2: Now that the package list has been updated, we should go ahead and install MariaDB. Just run the following command on the Ubuntu terminal: 

sudo apt install mariadb-server

You may be prompted to type the password for sudo user. 

Installing MariaDB on Ubuntu Step 3: The MariaDB service should be started automatically. However, you can verify its status by running the following command:

sudo systemctl status mariadb

It should be active and running. 

To know the version of MariaDB that has been installed, run the following command:

mysql -V

The output should be the version of MariaDB running on your computer. 

This will be a confirmation that you’ve successfully installed MariaDB on your Ubuntu system. 

Installing MariaDB from MariaDB Repositories

The official MariaDB repositories normally host the latest versions of MariaDB. Before starting the installation, it will be good for you to visit the official MariaDB repository page and check the latest version of MariaDB. 

The installation can be done by following the steps given below:

Installing MariaDB on Ubuntu Step 1: Run the following command to add the MariaDB GPG key to the system:

sudo apt-key adv --recv-keys --keyserver hkp:// 0xF1656F24C74CD1D8

Installing MariaDB on Ubuntu Step 2: Once the key has been imported, run the following command to add the MariaDB repository:

sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] bionic main'

In case you get an error message that says, “add-apt-repository command not found”, just install the “software-properties-common” package. 

Installing MariaDB on Ubuntu Step 3: Before installing any package from the MariaDB repository, you should first update the package list. This requires you to run the following command:

sudo apt update

Installing MariaDB on Ubuntu Step 4: After the repository has been added, run the following command to install the MariaDB package:

sudo apt install mariadb-server

Installing MariaDB on Ubuntu Step 5: The MariaDB service should be started automatically. To verify its status, run the following command:

sudo systemctl status mariadb

It should be active and running. 

Installing MariaDB on Ubuntu Step 6: You can check the version of MariaDB installed on your computer by running the following command:

mysql -V

Hevo Data, Seamless Data Migration to AWS Redshift

Hevo is a No-code Data Pipeline that offers a fully managed solution to set up data integration from 100+ data sources (including 30+ Free Data Sources) and will let you directly load data to AWS Redshift or a Data Warehouse of your choice. It will automate your data flow in minutes without writing any line of code. Its fault-tolerant architecture makes sure that your data is secure and consistent. Hevo provides you with a truly efficient and fully automated solution to manage data in real-time and always have analysis-ready data.

Get Started with Hevo for Free

Check out what makes Hevo amazing:

  • Secure: Hevo has a fault-tolerant architecture that ensures that the data is handled in a secure, consistent manner with zero data loss.
  • Schema Management: Hevo takes away the tedious task of schema management & automatically detects schema of incoming data and maps it to the destination schema.
  • Minimal Learning: Hevo, with its simple and interactive UI, is extremely simple for new customers to work on and perform operations.
  • Hevo Is Built To Scale: As the number of sources and the volume of your data grows, Hevo scales horizontally, handling millions of records per minute with minimal latency.
  • Incremental Data Load: Hevo allows the transfer of data that has been modified in real-time. This ensures efficient utilization of bandwidth on both ends.
  • Live Support: The Hevo team is available round the clock to extend exceptional support to its customers through chat, email, and support calls.
  • Live Monitoring: Hevo allows you to monitor the data flow and check where your data is at a particular point in time.
Sign up here for a 14-Day Free Trial!

Configuring MariaDB Security

To secure the MariaDB installation, we should run the security script that comes with MariaDB. The script should secure the less secure settings that come with MariaDB. For example, sample users and remote root logins. 

To execute the security script, run the following command from Ubuntu terminal:

sudo mysql_secure_installation

You will be taken through a series of instructions to help you improve the security of your MariaDB installation. This will include setting up the password for the root user, removing the anonymous user, removing the test database, and restricting root user access to the local host. 

The script will reload the privilege tables so that changes may take effect immediately. The steps will be explained in detail and you should answer by typing “Y” for “Yes”. 

Connecting to MariaDB

It is possible for you to establish a connection to the MariaDB server from your Ubuntu terminal using the MariaDB client. To log into MariaDB as the root user, run the following command:

mysql -u root -p

You will be prompted to enter the root password that you set when running the security script. If the authentication process runs successfully, you will be presented with the MariaDB terminal. 

You can now run SQL commands against your MariaDB Server. The SQL commands will help you perform tasks like creating databases, creating tables, inserting data into the tables, updating, and retrieving data from tables. 

For example, let’s create a database and give it the name sampledb. Run the following command on the MariaDB terminal:

create database sampledb;

To work on the database, you must select it. Run the following command:

use sampledb

Let us create a table within the database. The table will be given the name testtb:

CREATE TABLE testtb (name VARCHAR(20), age INTEGER)

The command should successfully create a table in the database. 

Limitations of Installing MariaDB on Ubuntu

Although it is possible to install MariaDB on Ubuntu, you may encounter a number of challenges including the following:

  1. Technical know-how is needed. The process of installing and configuring MariaDB on Ubuntu is very technical. This means that technical expertise is needed for this. 
  2. The process is prone to errors. This comes as a result of conflicts in versions of different packages installed in the Ubuntu system. 


In this article, you learned the steps for Installing MariaDB on Ubuntu, the method to configure and connect it along the limitations of the deployment. If you are interested in setting up MariaDB on a Raspberry Pi you can find the guide here.

Integrating and analyzing data from a huge set of diverse sources can be challenging, this is where Hevo comes into the picture. Hevo Data, a No-code Data Pipeline helps you transfer data from a source of your choice in a fully automated and secure manner without having to write the code repeatedly. Hevo with its strong integration with 100+ sources & BI tools, allows you to not only export & load Data but also transform & enrich your Data & make it analysis-ready in a jiffy.

Visit our Website to Explore Hevo

Want to take Hevo for a spin? Sign Up for a 14-day free trial and experience the feature-rich Hevo suite first hand.

Share your experience of installing MariaDB on Ubuntu in the comments section below!

Nicholas Samuel
Freelance Technical Content Writer, Hevo Data

Skilled in freelance writing within the data industry, Nicholas is passionate about unraveling the complexities of data integration and data analysis through informative content for those delving deeper into these subjects. He has written more than 150+ blogs on databases, processes, and tutorials that help data practitioners solve their day-to-day problems.

No-code Data Pipeline For MariaDB