How to Install MariaDB in Linux [5 Easy Steps]

How to Install MariaDB in Linux [5 Easy Steps]- linuxnasa

In this tutorial, we will learn about how to install MariaDB in Linux using 5 easy steps. There are many database management system technologies available like MySQL, PostgreSQL, SQLite, MariaDB, Oracle Database etc. Databases are used in any application for storing the data. Each of the mentioned databases has its own features to offer along with limitations. We will learn about MariaDB database system and understand the basic about it. We will then look at  how it is installed in CentOS 7 operating system which is one of the distribution of Linux. So let’s begin the tutorial.

 

MariaDB Overview

MariaDB is an open source relational database management system. It is a fork of MySQL which means it is compatible replacement for MySQL database technology. MariaDB aims to maintain open source freedom and ensures that the MySQL codebase remains open. MariaDB is highly compatible with MySQL and offers additional features, performance optimizations and storage engines.

MariaDB is widely used database system and has got the scope in many fields. Some of the major areas where MariaDB is preferred are motioned below.

Web Applications: Web applications developers uses MariaDB as backend database. Content management systems, e-commerce platforms and other web-based applications are the common applications that uses MariaDB.

Data Warehousing: MariaDB is used for data warehousing tasks, storing and analyzing large volumes of data.

Analytics: MariaDB supports analytical processing and reporting tasks which makes it useful for business intelligence applications.

Geospatial Data: MariaDB has built-in support for geospatial data types and indexes which makes it suitable for applications involving geographic information systems (GIS).

 

How to Install MariaDB in Linux [5 Easy Steps]

Also Read: Python Pandas Functions for Data Scientists [Top 10 Functions]

Since we are installing the MariaDB in CentOS 7 operating system, we will install the MariaDB rpm using Yum package manager. Different Linux distribution uses different package manager (apt-get, dnf etc) . We will install 3 different MariaDB packages. These are  MariaDB, MariaDB-server and MariaDB-libs. The MariaDB package will  install the client tools. MariaDB server will install the servers and MariaDB-libs will contain the supporting libraries. The later package will be pulled-in as dependency so we do not have to specify it in the yum installation command.

Prerequisite

  • Linux RHEL/CentOS 7 distribution installed.
  • User with sudo privilege/root user.
  • Yum Package Manager Enabled.
  • Basic understanding of Linux Commands.

 

Step-1: Install MariaDB RPMs

In this step, we will install all the MariaDB rpms using below command. If the the rpm installation is successful, it will print complete at the end of command output as shown below.

[root@linuxnasa ~]# yum install -y mariadb mariadb-server
Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

Determining fastest mirrors
epel/x86_64/metalink | 29 kB 00:00:00
* base: ftp.funet.fi
* centos-qemu-ev: ftp.funet.fi
* epel: www.nic.funet.fi
..........................................................................................
updates | 2.9 kB 00:00:00
(1/3): epel/x86_64/updateinfo | 1.0 MB 00:00:00
(2/3): updates/7/x86_64/primary_db | 24 MB 00:00:00
(3/3): epel/x86_64/primary_db | 7.0 MB 00:00:01
Resolving Dependencies
--> Running transaction check
---> Package mariadb.x86_64 3:10.1.20-2.el7 will be installed
................................................................................................
---> Package socat.x86_64 0:1.7.3.2-2.el7 will be installed
................................................................................................
---> Package perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================================
Package Arch Version Repository Size
===================================================================================================================================
Installing:
mariadb x86_64 3:10.1.20-2.el7 centos-openstack-rocky 6.3 M
mariadb-server x86_64 3:10.1.20-2.el7 centos-openstack-rocky 19 M
Installing for dependencies:
lsof x86_64 4.87-6.el7 base 331 k
mariadb-common x86_64 3:10.1.20-2.el7 centos-openstack-rocky 63 k
mariadb-config x86_64 3:10.1.20-2.el7 centos-openstack-rocky 26 k
mariadb-errmsg x86_64 3:10.1.20-2.el7 centos-openstack-rocky 200 k
perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 base 32 k
.........................................................................................................
mariadb-libs x86_64 3:10.1.20-2.el7 centos-openstack-rocky 643 k

Transaction Summary
===================================================================================================================================
Install 2 Packages (+13 Dependent packages)
Upgrade ( 1 Dependent package)

Total download size: 28 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/16): lsof-4.87-6.el7.x86_64.rpm | 331 kB 00:00:00
....................................................................................................
(16/16): mariadb-server-10.1.20-2.el7.x86_64.rpm | 19 MB 00:00:03
----------------------------------------------------------------------------------------------
Total 6.9 MB/s | 28 MB 00:00:04
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : perl-Data-Dumper-2.145-3.el7.x86_64 1/17
Installing : 3:mariadb-config-10.1.20-2.el7.x86_64 2/17
....................................................................................
Installing : 3:mariadb-server-10.1.20-2.el7.x86_64 16/17
Cleanup : 1:mariadb-libs-5.5.65-1.el7.x86_64 17/17
Verifying : 3:mariadb-errmsg-10.1.20-2.el7.x86_64 1/17
Verifying : perl-DBI-1.627-4.el7.x86_64 2/17
....................................................................................
Verifying : 1:mariadb-libs-5.5.65-1.el7.x86_64 17/17

Installed:
mariadb.x86_64 3:10.1.20-2.el7 mariadb-server.x86_64 3:10.1.20-2.el7

Dependency Installed:
lsof.x86_64 0:4.87-6.el7 mariadb-common.x86_64 3:10.1.20-2.el7 mariadb-config.x86_64 3:10.1.20-2.el7
mariadb-errmsg.x86_64 3:10.1.20-2.el7 perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7
perl-DBD-MySQL.x86_64 0:4.023-6.el7 perl-DBI.x86_64 0:1.627-4.el7 perl-Data-Dumper.x86_64 0:2.145-3.el7
perl-IO-Compress.noarch 0:2.061-2.el7 perl-Net-Daemon.noarch 0:0.48-5.el7 perl-PlRPC.noarch 0:0.2020-14.el7
socat.x86_64 0:1.7.3.2-2.el7

Dependency Updated:
mariadb-libs.x86_64 3:10.1.20-2.el7

Complete!

 

Step-2: Verify the RPM Installation

In this step, we will verify if all the MariaDB rpms are installed successfully using below command.

[root@linuxnasa ~]# yum list installed | grep ^mariadb
mariadb.x86_64          3:10.1.20-2.el7 @linuxnasa
mariadb-common.x86_64   3:10.1.20-2.el7 @linuxnasa
mariadb-config.x86_64   3:10.1.20-2.el7 @linuxnasa
mariadb-errmsg.x86_64   3:10.1.20-2.el7 @linuxnasa
mariadb-libs.x86_64     3:10.1.20-2.el7 @linuxnasa
mariadb-server.x86_64   3:10.1.20-2.el7 @linuxnasa

 

NOTE:

You can also use command “rpm -qa | grep mariadb” to check if mariadb rpms are installed.

 

Step-3:  Start MariaDB Service

In this step, we will start the MariaDB service and make it persistent so that it starts at system boot using below command.

First, start the MariaDB service using below command.

[root@linuxnasa ~]# systemctl start mariadb

Next, to make the MariaDB service persistent, execute below command.

[root@linuxnasa ~]# systemctl enable mariadb 
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

Next, check if MariaDB service is in running state using below command. It must be in active state.

[root@linuxnasa ~]# systemctl status mariadb
● mariadb.service - MariaDB 10.1 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2023-10-31 19:39:29 IST; 1min 38s ago
Main PID: 11027 (mysqld)
Status: "Taking your SQL requests now..."
CGroup: /system.slice/mariadb.service
└─11027 /usr/libexec/mysqld --basedir=/usr

Oct 31 19:39:28 linuxnasa mysql-prepare-db-dir[10853]: See the MariaDB Knowledgebase at http://mariadb.com/kb or the
Oct 31 19:39:28 linuxnasa mysql-prepare-db-dir[10853]: MySQL manual for more instructions.
Oct 31 19:39:28 linuxnasa mysql-prepare-db-dir[10853]: Please report any problems at http://mariadb.org/jira
Oct 31 19:39:28 linuxnasa mysql-prepare-db-dir[10853]: The latest information about MariaDB is available at http://mariadb.org/.
Oct 31 19:39:28 linuxnasa mysql-prepare-db-dir[10853]: You can find additional information about the MySQL part at:
Oct 31 19:39:28 linuxnasa mysql-prepare-db-dir[10853]: http://dev.mysql.com
Oct 31 19:39:28 linuxnasa mysql-prepare-db-dir[10853]: Consider joining MariaDB's strong and vibrant community:
Oct 31 19:39:28 linuxnasa mysql-prepare-db-dir[10853]: https://mariadb.org/get-involved/
Oct 31 19:39:28 linuxnasa mysqld[11027]: 2023-10-31 19:39:28 140359704082624 [Note] /usr/libexec/mysqld (mysqld 10.1.20-Ma...27 ...
Oct 31 19:39:29 linuxnasa systemd[1]: Started MariaDB 10.1 database server.
Hint: Some lines were ellipsized, use -l to show in full.

 

Step-4: Open Firewall for Database Connections

In this step, we will use firewalld service to open firewall for MariaDB service using below command.

[root@linuxnasa ~]# firewall-cmd --permanent --add-service mysql
success

Next, reload the firewall rules so that current changes are persistent. Use below command.

[root@linuxnasa ~]# firewall-cmd --reload
success

 

Step-5: Verify MariaDB Process

In this step, we will check if MariaDB process is running using below command. It must show the MariaDB service in the output.

[root@linuxnasa ~]# ps -ef | grep mysql
mysql 11027 1 0 19:39 ? 00:00:00 /usr/libexec/mysqld --basedir=/usr
root 11452 8912 0 19:46 pts/0 00:00:00 grep --color=auto mysql

 

Summary

We have successfully installed MariaDB on Linux. Now we are ready to create databases and practice the SQL concepts. To learn how to create and use databases in MariaDB, you  can follow the tutorial,  How to Create Database in MariaDB.

 

Leave a Comment