How to Install MariaDB on Ubuntu 20.04

How to Install MariaDB on Ubuntu

In this tutorial, We will learn how to install MariaDB on Ubuntu 20.04. It is one of the most popular open-source packages in Linux. MariaDB is the DBMS. It works as a backend with Linux System for web or mobile applications. It provides high performance and can handle high loads. Not only that, but it supports query cache and can be optimized further.

Prerequisites

We need an Ubuntu 20.04 server with root access.

Now Install MariaDB

In the following steps, we will learn how to install MariaDB.

  • Update the repositories and install the latest version of MariaDB:
sudo apt update
sudo apt install mariadb-server
  • After the successful installation, MariaDB service will automatically start. Let’s check the status with the below command.
sudo systemctl status mariadb

The above output shows that the MariaDB service is active.

  • Now setup the MySQL.
mysql_secure_installation

Login as root

To interact with the MariaDB server using the command line, we use mysql client utility or we can also use the alias MariaDB. This utility is installed as the dependency of the MariaDB server.

Read also: How to Change Remote URL in Git?

Login in to the MariaDB server as the root user:

sudo mysql

MariaDB presents a welcome message as:

If we want to access the MariaDB server by using an external program like PhpMyAdmin, you can access it in two ways:

  • Change the authentication method form auth_socket to
    mysql_native_password.
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'strong_password';
FLUSH PRIVILEGES;
  • Create a new user with all the privileges to access all databases. It will be another admin user as root user will be still master user.
GRANT ALL PRIVILEGES ON *.* TO 'New_user'@'localhost' IDENTIFIED BY 'strong_password';

Replace New_user and strong_password with your desired user and password.

Conclusion

In the tutorial, we have learned how to install MariaDB on Ubuntu 20.04. To learn detailed information about, how to manage MariaDB accounts, privileges, databases, etc. You can visit our other blog to manage MySQL databases and users.

If you guys have any quires related to this tutorial, Let me know in the comment.