How to install MariaDB on Ubuntu 22.04?

Overview

MariaDB is a popular open-source relational database management system that is built to handle high concurrency, provide strong security, and scale to large environment. It is a close drop-in replacement for MySQL and is easy to install. It offers more features, storage engines, and extensive replication features.

The following tutorial will demonstrate the steps to install MariaDB on Ubuntu 22.04.

Prerequisites

There are certain prerequisites that need to be met before you begin.

  • Ubuntu 22.04 LTS configured with non-root sudo user privileges.

  • A firewall setup with UFW.

Get Started

Step 1: Installation

  • Initialize package management with apt to get the latest security patches and software features.

sudo apt update
  • Install the relevant package for MariaDB.

sudo apt install mariadb-server

The installation is successful.

Note: As the default setup renders an insecure MariaDB installation, the mariadb-server package will not prompt you to configure the server's security by setting up a password.

Step 2: Setup

  • To improve the security of your MariaDB server, you should use the security script that is included with the installation. This script adds security features such as protection for remote root login and account restrictions for sample users.

sudo mysql_secure_installation

Now, a set of prompts should appear that will help you change the security options for your MariaDB installation. You must input the current database root password at the first prompt. Press ENTER to signify 'none' because you haven't yet created one.

You will then be prompted to choose whether you want to create a database root password. You shouldn't alter the configured authentication methods for the root account for MariaDB because it is strongly linked to automated system upkeep on Ubuntu. Enter 'n' and proceed by pressing ENTER.

For, all the preceding prompts, if you wish to accept the defaults, enter 'y', otherwise enter 'n'. These cues will prompt you to deactivate root logins that take place remotely and disposal of test database and anonymous accounts.

Step 3: Testing

Now that the security for MariaDB is configured, let's test MariaDB.

  • After successful setup, Mariadb will automatically begin its operations. You can verify this by checking its status using the following command:

sudo systemctl status mariadb

The output shows that the service is active and running.

  • However, if your MariaDB is inactive, you can activate it with the following command:

sudo systemctl start mariadb
  • If you would like to run an additional check, try establishing a connection to the database using the mysqladmin tool, a client that enables you to issue administrative commands.

sudo mysqladmin version

Conclusion

In this tutorial, we have gone over how to install MariaDB, and now there are plenty of tasks you can perform with your new MariaDB server, such as implementing SQL queries, importing and exporting databases, etc.

Last updated