Sunday, September 25, 2022

How to install MariaDB on Ubuntu 20.04

In this article, we want to teach you How to install MariaDB on Ubuntu 20.04.

Let’s see what MariaDB is first.

What is MariaDB?

MariaDB Server is one of the most popular open-source relational databases. It’s made by the original developers of MySQL and guaranteed to stay open source. It is part of most cloud offerings and the default in most Linux distributions.

How to install MariaDB on Ubuntu 20.04

Requirements for installing MariaDB on Ubuntu

For installing MariaDB you need Ubuntu 20.04 server and the server should have a non-root user and a firewall configured with UFW. visit our article about the Initial server setup with Ubuntu 20.04.

Install MariaDB on Ubuntu 20.04

For installing MariaDB, first, you should update the index packages with the following command:

sudo apt update

Then install the MariaDB package with the following command:

sudo apt install mariadb-server

Now MariaDB on Ubuntu 20.04 is installed but it will not ask you to set passwords or any other changes.

How to Configure MariaDB on Ubuntu 20.04

In this step you need to run security scrips for the new MariaDB installation with the following command:

sudo mysql_secure_installation

This will ask you to make some changes like the database root password. Because you have not set up a password above press Enter for none to continue.
After that, you will ask to set up a root password type N to continue.

Create an administrative user in your MariaDB

In this step, you can create a new account called admin with the same privileges as the root account with password authentication.
Open MariaDB on Ubuntu 20.04with the following command:

sudo mariadb

Then create a new user with root privileges and password-based access with the following command:

GRANT ALL ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;

Then flush the privileges with the following command:

FLUSH PRIVILEGES;

To exit from the MariaDB shell run the following command:

exit

Now you can test your MariaDB.

Test MariaDB on Ubuntu 20.04

When the installation is finished MariaDB starts running automatically, you can check this with the following command:

sudo systemctl status mariadb

You will see the active running in your output.

Note: if your MariaDB isn’t running you can use the following command to start it.

sudo systemctl start mariadb

You can use the MySQL admin tool that lets you run administrative commands.
For example:

sudo mysqladmin version

Or with an administrative user you can run the following command:

mysqladmin -u admin -p version

Hope you enjoy this article about How to install MariaDB on Ubuntu 20.04.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

POPULAR TAGS

Most Popular