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.
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.
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.
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.
We now need to start the MariaDB server using the following command, as shown in Figure 5.
sudo systemctl start mariadb
To check if our MariaDB server has started, we use the following command, as shown in Figure 6.
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):
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.
We can now check the existing databases (as shown in Figure 9), using the following command:
show databases;
Now, to create a database, we can use the following command just like MySQL, as shown in Figure 10:
Now we can use our database normally. To exit the command line, we can just use the exit command (as shown in Figure 11).
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!