Get Rewarded! We will reward you with up to €50 credit on your account for every tutorial that you write and we publish!

How to install MariaDB 10.6 on Ubuntu 20.04

profile picture
Author
Rahul Mukati
Published
2022-02-24
Time to read
5 minutes reading time

About the author- Founder at ZagFox Technologies

Table of Contents

Introduction

In this tutorial I'm going to cover how to install MariaDB 10.6 on an Ubuntu 20.04 server.

Prerequisites

Step 1 - Login to server

Login to your server with root user:

ssh root@10.0.0.1

Step 2 - Update your server

After a successful login, we need to update our server.

For this we run the following command:

sudo apt-get update && sudo apt-get upgrade -y

Step 3 - Install required packages

Next, we will install software-properties-common. Run below command for that.

sudo apt install software-properties-common -y

Step 4 - Add MariaDB APT Repository

Now with the below commands, we are going to add MariaDB signing key and add MariaDB APT repository.

curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
sudo bash mariadb_repo_setup --mariadb-server-version=10.6

You’ll get an output with contents like the ones shown below:

[info] Checking for script prerequisites.
[info] Repository file successfully written to /etc/apt/sources.list.d/mariadb.list
[info] Adding trusted package signing keys...
[info] Running apt-get update...
[info] Done adding trusted package signing keys

Step 5 - Install MariaDB 10.6

Now, we will make MariaDB 10.6 installation by running the below command:

sudo apt update
sudo apt install mariadb-server

Step 6 - Secure MariaDB installation

Once MariaDB is installed, run the below MySQL script to secure MariaDB.

sudo mariadb-secure-installation

You will be asked for some options [Y/n], you can take a look below for that.

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] Y
Enabled successfully!
Reloading privilege tables..
 ... Success!


You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] Y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Step 7 - Testing MariaDB

Now we are all set, MariaDB is installed and now we can test its status by running below command.

sudo systemctl status mariadb

You'll receive output that is similar to the following:

● mariadb.service - MariaDB 10.6.4 database server
   Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: active (running) since Tue 2021-10-19 11:37:25 UTC; 9s ago
     Docs: man:mariadbd(8)
           https://mariadb.com/kb/en/library/systemd/
 Main PID: 3023 (mariadbd)
   Status: "Taking your SQL requests now..."
    Tasks: 14 (limit: 4703)
   CGroup: /system.slice/mariadb.service
           └─3023 /usr/sbin/mariadbd

If MariaDB isn’t running, you can start it with the command:

sudo systemctl start mariadb

Step 8 - Enable MariaDB to start on server reboot

Run the below command to enable MariaDB to automatically start when server is rebooted.

sudo systemctl enable mariadb

Conclusion

We were able to install MariaDB 10.6 on an Ubuntu 20.04 server.

License: MIT
Want to contribute?

Get Rewarded: Get up to €50 in credit! Be a part of the community and contribute. Do it for the money. Do it for the bragging rights. And do it to teach others!

Report Issue

Discover our

Dedicated Servers

Configure your dream server. Top performance with an excellent connection at an unbeatable price!

Want to contribute?

Get Rewarded: Get up to €50 credit on your account for every tutorial you write and we publish!

Find out more