How to install & configure MariaDB on Ubuntu

Managing databases on Ubuntu is important for many applications from small websites to enterprise systems. MariaDB, is a popular opensource database management system that offers a robust solution for storing and retrieving data efficiently.

In this article, we’ll learn about How to install & configure MariaDB on Ubuntu by understanding each step in detail along with the practical implementation and so on.

How to Install and Configure MariaDB on Ubuntu?

Installing and configuring MariaDB on Ubuntu involves several key steps to ensure a successful setup. We’ll start by updating the system to ensure compatibility with the latest packages and dependencies. Then, we’ll install the MariaDB server and client, followed by starting and enabling the MariaDB service.

Next, we’ll secure the MariaDB installation by setting up a root password and configuring additional security settings. Finally, we’ll demonstrate how to log in to the MariaDB server and perform basic database operations.

Below are the steps follow to Install and Configure MariaDB on Ubuntu.

  1. Update your System
  2. Install MariaDB Server and MariaDB Client
  3. Start And Enable MariaDB
  4. Check the Status of MariaDB Server
  5. Secure and Configure the MariaDB Installation
  6. Login to the MariaDB Server
  7. Open and Exit the Database

Let’s understand each steps with practical implementations:

Step 1: Update your System

To begin with the installation, you must update your Ubuntu system to make sure that you have the newest package lists and also dependencies. By doing this, it prevents problems or crashes that may arise during the installation of MariaDB. To update your system use the below command.

Command:

sudo apt update

Output:

Update the Ubuntu System

Step 2: Install MariaDB Server and MariaDB Client

By running the following command, the system will Install & fetch the necessary MariaDB packages from the Ubuntu repositories and install them on our machine. The installation process may take some time, depending on your internet connection speed and system resources.

Command:

sudo apt install mariadb-server mariadb-client -y

Output:

Installing the MariaDB Server & Client

Step 3: Start And Enable MariaDB

By default, the MariaDB database engine starts automatically at the time of installation. However, we can manually start the service and ensure it starts automatically after system reboots by using the following commands:

Command:

sudo systemctl start mariadb

This command will start the MariaDB service immediately. The systemctl utility is used to manage systemd services on Ubuntu and other Linux distributions that use systemd as the init system.

sudo systemctl enable mariadb

Output:

Enable the Service

Step 4: Check the Status of MariaDB Server

To check whether the MariaDB server is running or not, wevcan use the following command. This command will display the current status of the MariaDB service along with other relevant information.

Command:

sudo systemctl status mariadb

Output:

Status of MariaDB

Step 5: Secure and Configre the MariaDB Installation

After installing the MariaDB server, it’s importnto secure it by setting up a root password and configuring additional security settings. This step is essential to prevent unauthorized access and ensure the integrity of your data. Follow the steps and commands below to secure your MariaDB installation.

Command:

sudo mysql_secure_installation

Output:

Securing the Installation

After entering the command sudo mysql_secure_installation and pressing Enter, you will be prompted to set a password for the MariaDB root user. This is an important step to secure your MariaDB installation and prevent unauthorized access.

Setting up the Password

As the mysql_secure_installation script progresses, you will encounter several prompts with the format [Y/n]. At each of these prompts, we should press “Enter” to accept the default option, which is “Yes” (Y).

After pressing “Enter” at each of these prompts, the script will proceed with the recommended security configurations. Once the script has completed all the security configurations.

MariaDB is Successfully Configured

Step 6: Login to the MariaDB Server

Now that we have successfully installed and secured the MariaDB server, we can easily log in to the MariaDB database by entering the password we created in Step 5.

Command:

sudo mysql -uroot -p

Output:

Logging into the MariaDB

Step 7: Open and Exit the Database

To verify that your database is configured correctly and to see the available databases, you can use the following command. After logging in to the MariaDB server successfully, you can execute the ” SHOW DATABASES; ” command to list all the databases currently available on your system.

Command:

show databases;

Output:

Database

To exit the MariaDB database server and return to the system’s command-line interface, we can use the following command.

Command:

exit

Output:

Exit the Database

Conclusion

Overall, Installing and configuring MariaDB on Ubuntu is a straightforward process that can be accomplished by following a few simple steps. By updating your system, installing the necessary packages, and securing your installation, you can have a reliable and efficient open-source database management system up and running in no time. Whether you are managing a small website or a large enterprise system.