en
  English
Phone :  +370 (5) 204-1903
Email: sales@1gbits.com
  1. Dedicated server
  2. Blog
  3. How to install MariaDB on Ubuntu 18.04

How to install MariaDB on Ubuntu 18.04

MariaDB is an open-source database management system that is a backward compatible replacement for MySQL. It is a multi-threaded relational database management system. MariaDB is maintained and developed by the MariaDB Foundation which comprises some of the original developers of MySQL.

Linux Tutorial Sep 29, 18 by Criss N 5 min Read
How to install MariaDB on Ubuntu 18.04

This is commonly used as an alternative for the MySQL portion of the LAMP stack. IT can be used as a direct replacement for MySQL. In this tutorial, we will go through two methods of installing MariaDB on your Ubuntu server (we recommend using the first one). Then we will set up MariaDB with the initial configurations and get it up and running.

Note that the following method is exactly the same for installing MariaDB on Ubuntu 16.04, Ubuntu 18.04 and Ubuntu 20.04.

Prerequisites

In order to get MariaDB set on your Ubuntu server, we will need:

  • A server running Ubuntu 18.04 operating system (can be replaced with Ubuntu 20.04 or Ubuntu 16.04)
  • A user account with sudo privileges
  • Basic understanding of Linux commands

Installing MariaDB on Ubuntu 18.04

We will be using MariaDB 10.3 version throughout the tutorial.

To install MariaDB on your server, we will need to update the packages index:

sudo apt update

Now the packages are updated, we can go ahead and install the latest version of MariaDB by issuing the following command:

sudo apt install mariadb-server

When prompted to continue, press y.

Once MariaDB will be installed successfully, it will start automatically and to check it for yourself, enter the following command. You will see an output similar to the one below.

sudo systemctl status mariadb

If the command does not end automatically, press q to exit back to the terminal.

To check for the version, you can use the following:

mysql –V

Congratulations, you successfully installed MariaDB on your Ubuntu 18.04 server. In the next part, we will go through the MariaDB installation process using the MariaDB repositories. If you already have the server set up you can skip the next section and move to the configurations.

Installing MariaDB using the MariaDB Repositories

Before we proceed with this installation, you should go to the MariaDB repository and check if there is a new version available for you to install. At the timing of writing this article, the most recent stable version was MariaDB 10.5.

First, we will add the software properties common package.

sudo apt-get install software-properties-common

Now we will go ahead and add the MariaDB GPG key to your system by entering the following command:

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

Now that we have added the key, we add the MariaDB repository using:

sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] https://mariadb.mirror.serveriai.lt/repo/10.5/ubuntu bionic main'

Now we’re all set. In order to install packages from the MariaDB repository, we will need to update the package list.

sudo apt update

Now that the repository is added install the MariaDB package with:

sudo apt install mariadb-server

Once the service will be activated automatically, enter the following command to verify if the service is running:

sudo systemctl status mariadb

Congratulations, you have successfully installed MariaDB on Ubuntu 18.04.

Configuring MariaDB

For new MariaDB installations, we need to include some security scripts. Running this script will change some default options. We will use it to block remote root logins and to remove unused database users.

Run the following command:

sudo mysql_secure_installation

Once this command is run, you will go through a series of prompts where you can make some changes. The first prompt will ask you to enter the current database root password, but we can ignore this since we didn’t set one up. Press Enter to skip to the next one.

From this point onwards you can press Y to go forward with the default security measures. This will remove some anonymous users and the test database, disable remote root logins, and load these new rules so that MariaDB immediately implements the changes you have made.

Connect to MariaDB from the command line

To connect to the MariaDB server through the terminal we can use the MariaDB client. To log in to the MariaDB server as the root user (the user you created in the previous step) type:

mysql -u root –p

If you configured a separate administrative user with password authentication, instead of root add the username of the separate account.

You will be prompted to enter the root password you have previously set when the mysql_secure_installation script was run. This means that MariaDB is up and running and that your user is able to authenticate successfully.

Conclusion

In this guide, we covered the installation of MariaDB on Ubuntu 18.04 and use it as a direct replacement for the SQL server. We added some security measures during the installation process and got it ready to be connected from the command line.

If you liked this tutorial, don’t forget to share it with your colleagues and your feedback is important to us. So let us know in the comments below!

author img

Criss N

I’m a master graduate in ICT and my passion has been towards the software from a very young age. I’m also a professional athlete and a developer. I have more than 6 years of SEO experience, webmaster and a huge fan of wordpress. I love working with coding and also a fan of networking specialities.

Generic placeholder image
Smithf947

2018 Oct 05, 09:10:43

Wonderful blog! I found it while surfing around on Yahoo News. Do you have any suggestions on how to get listed in Yahoo News? I've been trying for a while but I never seem to get there! Thanks dddkegfggefdddfa

Leave A Comment