2018-09-22 · Tools

How to install mariadb 10.3 on centos 7

MariaDB Server is one of the most popular open source databases in the world. It is the default database in leading Linux distributions – Arch Linux, CentOS, Debian, Fedora, Manjaro, openSUSE, Red Hat Enterprise Linux and SUSE Linux Enterprise, to name a few.

mariadb

MariaDB server is a community developed fork of MySQL server. Started by core members of the original MySQL team, MariaDB is designed as a drop-in replacement of MySQL(R) with more features, new storage engines, fewer bugs, and better performance.
MariaDB can be an better choice for choice for database professionals looking for a robust, scalable, and reliable SQL server.

In this tutorial, we will explain how to install the latest version of MariaDB on a CentOS 7.

The procedure to install MariaDB on an CentOS Linux 7 is as follows:

1.Login to your cloud server or bare metal server using ssh command:

ssh user@cloud-server-ip

2.To add MariaDB yum repository:

sudo vim /etc/yum.repos.d/MariaDB.repo

3.Install MariaDB

sudo yum install -y MariaDB-server MariaDB-client

4.Secure MariaDB Install

sudo mysql_secure_installation

5.Test it

Let us see all steps, commands and configuration in details.

Step 1 – Configure MariaDB repo for CentOS 7 (See Resources)

Run command:

sudo vim /etc/yum.repos.d/MariaDB.repo

Copy and paste:

# MariaDB 10.3 CentOS repository list - created 2018-09-20 15:38 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.3/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Step 2 – Install MariaDB Server

After the file is in place, install MariaDB with:

sudo yum install MariaDB-server MariaDB-client -y

Step 3 – Start/stop/restart/status MariaDB Server

sudo systemctl enable mariadb # run at server boot time

sudo systemctl start mariadb # Start MariaDB command

sudo systemctl stop mariadb # Stop MariaDB command

sudo systemctl restart mariadb # Restart MariaDB command

sudo systemctl status mariadb # Find status of MariaDB server command

Step 4 – Secure MariaDB Install

MariaDB includes a security script “mysql_secure_installation” to change some of the less secure default options for things like remote root logins and sample users.

In this tutorial, im gonna explain how to secure mariadb with mysql_secure_installation on Redhat/CentOS 7

mysqld-mysql_secure_installation1

Next step is to set a password for the user root and some others things to make your mariadb more secure.

mysqld-mysql_secure_installation2

Step 4 – Test it

Once the configuration is complete, connect to MariaDB server using the following command.

# mysql -u root -p

Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 10.3.2-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

Let’s create a new database

create database TestDB character set utf8mb4 collate utf8mb4_unicode_ci;

Create a database user account and Grant permissions

grant all privileges on TestDB.* to 'TestUser'@'%' identified by 'TestPassw' with grant option;

Once you have grant the permissions that you want to set up for your new users, make sure to reload all the privileges using the following command:

flush privileges;

Reference:

HOW TO INSTALL MARIADB 10.3 ON CENTOS 7 / RHEL 7
MariaDB