How to Install MariaDB on Debian/Ubuntu

How To Install MariaDB On Debian Ubuntu

In this tutorial, we will discuss how to install MariaDB on Debian/Ubuntu operating system. Talking about MariaDB, It is open-source software under the MariaDB foundation. It was developed by MySQL developers. MariaDB is an alternative to MySQL with a few limitations. Even in XAMPP, MySQL is replaced with MariaDB. MariaDB supports both structured and semi-structured data. This makes MariaDB an ideal technology for BigData.

Some other details about MariaDB are as follows:

The package used: mariadb-server
Default Port : 3306
Configuration file: /etc/my.cnf
Log File: /var/log/mariadb/mariadb.log

Let’s see how to install MariaDB on Ubuntu/Debian. Generally, it is recommended to install MariaDB from the Debian repositories.

There are two methods to install MariaDB:

  1. Install MariaDB on Debian via apt
  2. Or Install MariaDB on Debian from MariaDB Repositories

Install MariaDB on Debian from apt Sources

Here, I have described the steps to install MariaDB. This process is quite straightforward and you’ll have no problem.

1. Updating the Packages

Let’s update the packages installed in Debian/Ubuntu. Here, we are using apt as it combines all the functionalities in one command.

The syntax is as follows:

# sudo apt update
Sudoupdate

2. Installing the mariadb-server Package

Now, we have our packages updated, let’s install mariadb-server package.

The syntax for this is as follows:

# sudo apt install mariadb-server
Maridbinstall

The processing goes on, and it will ask you to “Do you want to continue?” answer “Y”. Hence, the installation will be completed.

3. Start the MariaDB Service

We need to check whether the MariaDB services are running or not. For this, we will use the service command.

The syntax is as follows:

# sudo service mariadb status
Mariadb Service Status
MariaDB Service Status

In the figure given above, you will notice the status active. This simply signifies that MariaDB has been successfully installed in the system.

Installing MariaDB from Official Repositories

Earlier, we discussed how to install MariaDB on Debian with the apt command. Let’s learn how to install MariaDB via their official repositories.

1. Enable MariaDB repository

The first step is to enable the MariaDB repository. By default, the MariaDB repository is present in Debian/Ubuntu. You need to enable it.

The syntax for this is as follows:

#sudo apt install software-properties-common dirmngr
Method1

After installing the software properties, you need to import the repository GPG key to your system. For this, run the following command given below:

# sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
Repoinstall1

The last command you need to run to completely enable the repositories is as follows:

sudo add-apt-repository 'deb [arch=amd64] http://mirror.23media.de/mariadb/repo/10.4/debian buster main'
Repo Install
Repo Install

After successfully running these three commands, your repositories are enabled.

2. Update the packages

The next step is to update the packages as we did before. It has been discussed above.

The syntax for the following is:

# sudo apt update
Sudoupdate 1

This command will update all the packages installed.

3. Install mariadb-server package

The next step is the same as we did before installing the mariadb server Package.

The syntax for this is as follows:

# sudo apt install mariadb-server
Methodstep4 2

This command will successfully install the server.

4. Start the services

Starting the services or verifying that the service has started or not is the last step. The command for this is as follows:

$ sudo service mariadb start
Mariadb Service Status
Mariadb Service Status

This command shows the status of MariaDB.

How to secure MariaDB in Debian/Ubuntu?

Security is the main concern for everyone. If you won’t use a password for authentication, anyone can easily steal your data. So it’s important to provide user authentication. MariaDB provides you the feature to add a user password.

The syntax for this is as follows:

# sudo mysql_secure_installation
Secureinstallation

It would ask you the password, remove anonymous users, and restrict root user access to the local machine. Hence, your DB will be secured.

Start MariaDB using the command in Debian/Ubuntu

After performing all the steps, start the MariaDB server using one of the following commands:

# sudo mysql
OR
# sudo mariadb
Start

This would start the server and you can begin working with the database.

Check the version of MariaDB

To know that which version is installed in your system, run the following command:

# sudo mariadb --version
Mariadb Version
MariaDB Version

This command will print the version of MariaDB installed.

How to Uninstall MariaDB server from Debian/Ubuntu

We know how to install MariaDB server in Ubuntu/Debian. But we should know how to uninstall it. Here, I have described the command:

# sudo apt --purge remove mariadb-server
Remove Mariadb

This command will uninstall all the packages of MariaDB from Debian/Ubuntu.

Conclusion

That’s it now! We have our very own MariaDB server installed on our system. For future updates to the package, all you’d need to do is to update the apt repository using apt update and then run apt upgrade. The mariadb-server package will be upgraded to the latest one automatically without you needing to go through this entire process again.

Leave a Comment

Your email address will not be published. Required fields are marked *