Installing and Using MariaDB on Ubuntu

0
866
installing mariaDB on ubuntu

MariaDB is a popular database server today, primarily because of its good performance and compatibility with MySQL. This article gives a short tutorial on how to install and use MariaDB on an Ubuntu machine.

MariaDB is an open source database server that supports relational databases. The developers of MySQL have developed this database and guarantee that MariaDB is going to stay open sourced. This popular database server is part of most major cloud offerings today, and gives great importance to stability and performance. MariaDB developers believe it is very important for it to be compatible with MySQL…and that is yet another reason for its popularity.

MariaDB has recently added clustering techniques using the Galera cluster, and is also compatible with Oracle databases.

Let us now see how we can install and use MariaDB on an Ubuntu machine.

First, let us update our packages by running the following command, as shown in Figure 1.

 Updating packages
Figure 1: Updating packages
sudo apt update

We can now install MariaDB. However, we first need to get the sudo permission by entering the following command:

sudo su

Now enter the following command to install the MariaDB server, as shown in Figure 2.

MariaDB server Installation
Figure 2: MariaDB server Installation
apt-get install mariadb-server

Sometimes you may not have what is needed to install MariaDB. So it will give you the instructions to first get the requirements, and only then will it be installed.

Command to open the configuration file
Figure 3: Command to open the configuration file

Now let us see how we can look at the configuration of the MariaDB we installed. Use the command shown in Figure 3. You can then view the configuration file, as shown in Figure 4.

The MariaDB configuration file
Figure 4: The MariaDB configuration file

We now need to start the MariaDB server using the following command, as shown in Figure 5.

 Starting MariaDB server
Figure 5: Starting MariaDB server
sudo systemctl start mariadb

To check if our MariaDB server has started, we use the following command, as shown in Figure 6.

 Checking the status of MariaDB
Figure 6: Checking the status of MariaDB
sudo systemctl status mariadb

You can use the following command to restart the MariaDB server:

sudo systemctl restart mariadb

Now that we have installed MariaDB, we need to save important data, and keep our database secure. Today, data is very important and valuable, making it all the more important to keep it safe and secure. So, here are the steps that will help you secure your MariaDB database.

First, we set up a password to login into the MariaDB database and set up an authorisation system, using the following command (Figure 7):

Securing the database
Figure 7: Securing the database
sudo mysql_secure_installation

Once we perform all the prompted actions and steps, our database is now secure and ready to use. Let us do that now.

First run the command, ‘sudo mysql’, as shown in Figure 8.

Starting the DB on command line
Figure 8: Starting the DB on command line

We can now check the existing databases (as shown in Figure 9), using the following command:

Checking the existing databases
Figure 9: Checking the existing databases
show databases;

Now, to create a database, we can use the following command just like MySQL, as shown in Figure 10:

Creating a database and checking the newly created one
Figure 10: Creating a database and checking the newly created one

Now we can use our database normally. To exit the command line, we can just use the exit command (as shown in Figure 11).

Exiting MariaDB from the command line
Figure 11: Exiting MariaDB from the command line

We have now understood how to install, use and secure our MariaDB database. It can be great fun to use new database servers and explore them. Do give this one a try!

LEAVE A REPLY

Please enter your comment!
Please enter your name here