How to install MariaDB on Ubuntu 20.04

s2 0

MariaDB is an open source relational database management system. It was originally developed as a backward compatible, binary drop-in replacement for MySQL.

MariaDB is developed and maintained by the original developers of MySQL and by the open source community.

This guide explains the installation and MariaDB on Ubuntu 20.04.


We assume that you have administrator access to the Ubuntu server, either as root or as a user with sudo privileges.

Install MariaDB on Ubuntu

At the time of this writing, the latest MariaDB version available in the Ubuntu repositories is version 10.3. To install it, run the following commands:

sudo apt updatesudo apt install mariadb-server

Once the installation is complete, the MariaDB service will start automatically. To verify that the database server is running, type the following:

sudo systemctl status mariadb

The output should show that the service is enabled and running:

● mariadb.service - MariaDB 10.3.22 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2020-05-20 16:52:07 UTC; 12s ago

That’s it. MariaDB has been installed and you can use it.

Log in as root

To interact with the MariaDB server from the command line, use the mysql Client utility or its alias mariadb. This tool is installed as a dependency on the MariaDB server package.

On Ubuntu, the MariaDB root user is from. authenticated auth_socket Plugin by default. The plugin works by checking that the local system user calling the client program matches the specified MariaDB username. This means that you cannot authenticate as root by providing a password.

To log into the MariaDB server as the root user:

sudo mysql

You will be presented with the MariaDB shell as shown below:

Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 61
Server version: 10.3.22-MariaDB-1ubuntu1 Ubuntu 20.04

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)]> Bye

If you want to log into your MariaDB server as root using an external program like phpMyAdmin, you have two options.

The first is to change the authentication method from auth_socket to mysql_native_password. You can do this by running the following command:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'very_strong_password';FLUSH PRIVILEGES;

The second recommended option is to create a new dedicated administrator with access to all databases:

GRANT ALL PRIVILEGES ON *.* TO 'administrator'@'localhost' IDENTIFIED BY 'very_strong_password';

You can give the administrator any name you want, but make sure you use a strong password.


We showed you how to install MariaDB on Ubuntu 20.04. Now that your database server is up and running, your next step could be learning how to manage MariaDB user accounts and databases.

If you have any questions or feedback, please feel free to leave a comment.