MariaDB is an open-source relational database management system. It was originally designed as a backward-compatible, binary drop-in replacement of MySQL.
MariaDB is developed and maintained by the original developers of MySQL and by the open-source community.
This guide explains how to install and MariaDB on Ubuntu 20.04.
We’re assuming that you have administrative access to the Ubuntu server, either as root or a user with sudo permissions.
Installing MariaDB on Ubuntu
At the time of writing this article, the latest MariaDB version available in Ubuntu’s repositories is version 10.3. To install it run the following commands:
sudo apt update
sudo apt install mariadb-server
Once the installation is completed, the MariaDB service will start automatically. To verify that the database server is running, type:
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 start using it.
Login 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 of the MariaDB server package.
On Ubuntu, MariaDB root user is authenticated by the
auth_socket plugin by default. The plugin works by checking whether the local system user invoking the client program matches the specified MariaDB user name. This means that you can’t authenticate as root by providing a password.
To log in to the MariaDB server as the root user type:
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 login to your MariaDB server as root using an external program such as phpMyAdmin, you have two options.
The first one is to change the authentication method from
mysql_native_password. You can do that by running the following command:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'very_strong_password';
The second, recommended option is to create a new dedicated administrative user with access to all databases:
GRANT ALL PRIVILEGES ON *.* TO 'administrator'@'localhost' IDENTIFIED BY 'very_strong_password';
You can name the administrative user anything you want, but make sure you use a strong password.
We have shown you how to install MariaDB on Ubuntu 20.04. Now that your database server is up and running, your next step could be to learn how to manage MariaDB user accounts and databases.
If you have any questions or feedback, feel free to leave a comment.