Install MariaDB on CentOS7

Install MariaDB on CentOS7

In this step-by-step guide, we will show you how to install mariaDB on CentOS7. MariaDB is a fork of MySQL relational database management systems (RDBMS).

Table of Contents

Introduction

MariaDB originated from the apprehensions of the initial developers that Oracle might acquire it in 2009. It was crafted with a focus on upholding compatibility with MySQL, encompassing features such as seamless integration as a drop-in replacement, binary parity with libraries, and precise replication of MySQL APIs and commands. This strategic design not only ensures a smooth transition for existing MySQL users but also fosters a cohesive ecosystem for developers, enabling them to leverage MariaDB’s capabilities without encountering significant migration hurdles.

Prerequisites

  • CentOS 7 Installation: Ensure that you have a clean installation of CentOS 7 on your system. You can download the CentOS 7 ISO from the official CentOS website and follow the installation instructions to set up your system.

  • Root Access: You’ll need root or sudo privileges to install packages and make system-level changes. If you’re not already logged in as root, make sure you have sudo privileges to execute commands.

  • Internet Connectivity: Ensure that your CentOS 7 system has access to the internet, as you’ll need to download packages from the repositories during the installation process.

Important: CentOS 7 will reach its end-of-life in June 2024. Plan to transition to a supported version before this date.

Update your system

Before installing MariaDB, update your system’s package manager repositories and installed packages to their latest versions. This ensures that you have access to the most up-to-date software packages and dependencies.

				
					$ sudo yum update -y
				
			

Firewall Configuration

 If a firewall is active on your CentOS 7 system, configure it to allow incoming connections to MariaDB ports (typically 3306 for MySQL/MariaDB) using the firewall-cmd command.

				
					$ sudo firewall-cmd --zone=public --add-port=3306/tcp --permanent

$ sudo firewall-cmd --reload
				
			

Disable MySQL (Optional):

If you do not have a clean install and MySQL is currently installed and MariaDB is intended to replace it, stop and disable the MySQL service to prevent potential conflicts.

				
					$ sudo firewall-cmd --zone=public --add-port=3306/tcp --permanent

$ sudo firewall-cmd --reload
				
			

Data Backup (if applicable):

If transitioning from an existing MySQL setup or if critical data resides in a MySQL database, safeguard your data by backing it up before initiating the MariaDB installation to mitigate any risks of data loss.

				
					mysqldump -u username -p database_name > backup.sql
				
			

Replace username with your MySQL username, database_name with the name of the database you want to back up, and backup.sql with the desired name of your backup file. When you run this command, you’ll be prompted to enter your MySQL password.

If you’re backing up all databases, you can use the --all-databases option:

				
					mysqldump -u username -p --all-databases > all_databases_backup.sql
				
			

This command will back up all databases accessible to the specified MySQL user. Remember to securely store your backup files in a safe location, as they contain sensitive data. Additionally, it’s a good practice to automate regular backups to ensure data safety and reliability.

Install MariaDB on CentOS7: Installation Procedure

Follow these steps to complete the install.

Install MariaDB (yum install)

Run the following command to install mariadb-server on your machine using yum.

				
					$ sudo yum install mariadb-server -y
				
			

The mariadb-server is at version 1:5.5.68-1 as of the date of this publication. Install the latest version on your machine.

				
					Loaded plugins: fastestmirror, langpacks 
Loading mirror speeds from cached hostfile 
  * base: mirror.umd.edu 
  * epel: epel.mirror.constant.com 
  * extras: mirrors.advancedhosters.com 
  * remi-php70: mirror.pit.teraswitch.com 
  * remi-php73: mirror.pit.teraswitch.com 
  * remi-safe: mirror.pit.teraswitch.com 
  * updates: mirror.ette.biz 
Resolving Dependencies 
--> Running transaction check
---> Package mariadb-server.x86_64 1:5.5.68-1.el7 will be reinstalled 
--> Finished Dependency Resolution 

Dependencies Resolved 
================================================================================================== 
Package                     Arch       Version       Repository       Size 
==================================================================================================
Installing: 
mariadb-server x86_64       1:5.5.68-1.el7           base             11 M 
...
Complete!
				
			

Start MariaDB

Start MariaDB server and run a status check to verify it’s running. 

				
					$ sudo systemctl start mariadb.service; sudo systemctl status mariadb.service

● mariadb.service - MariaDB database server 
    Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled) 
    Active: active (running) since Wed 2021-11-17 02:20:58 EST; 45min ago 
  Main PID: 1241 (mysqld_safe) 
  CGroup: /system.slice/mariadb.service 
          ├─1241 /bin/sh /usr/bin/mysqld_safe --basedir=/usr 
          └─1474 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin 
          --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.s...
				
			

Install MariaDB on CentOS7: Configuring MariaDB

Run the mysql_secure_installation procedure to complete the database setup. Click here for details on how to proceed.

				
					$ sudo mysql_secure_installation
				
			

Uninstalling MariaDB

Uninstalling mariaDB is as simple as installing it using the yum command (below):

				
					$ sudo yum remove mariadb-server
				
			

Conclusion

We’ve delved into the historical roots of MariaDB and its connection to MySQL, as well as walked through the installation, configuration, and uninstallation processes. Now, let’s dive into the rich array of commands available in MariaDB that enable you to explore and acquaint yourself with its functionality. Here’s a curated selection of the most frequently used commands to get you started.

Did you find this article useful? Your feedback is invaluable to us! Please feel free to share your thoughts in the comments section below.

Related Posts

Leave a Reply

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