• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
sharadchhetri

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

How to install Mariadb 10.4 server on CentOS 8 / RHEL 8

June 14, 2020 by Sharad Chhetri Leave a Comment

Do you want to know how to install Mariadb 10.04 server on CentOS 8/RHEL 8 ? This post will help you to install MariaDB server. MariaDB is now defacto RDBMS in RHEL/CentOS after its seperation from the MySQL. We have already written other post on Mariadb Server, hence we will directly go to installation section.

In this post, we will do all the steps by creating the shell script and executing it. When we do our task by using scripts, it automates the task and quite faster then manual efforts.

Before we jump into installation section, we would like to strongly suggest to read the release notes of MariaDB 10.4 server.

Steps To Install MariaDB 10.4 Server on CentOS 8/RHEL 8

First we will create a simple bash script for installing the MariaDB Server.

Step 1: Create a file for creating bash script

vi install_mariadb_10.04_centos8.sh

Copy-Paste and save the given below content in the file.

#/bin/bash
#
# Install MariaDB Server version 10.4 on CentOS 8.
# Blog: https://sharadchhetri.com

# Declare a variable for new mariadb root password. If it is not given, then script won't run and will show help.
#

_root_new_passwd=${1?Require to give new root password, use -n }

# create new yum mariadb repo file and move to /etc/yum.repos.d dir
cat <mariadb.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/centos8-amd64
module_hotfixes=1
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF
sudo mv mariadb.repo /etc/yum.repos.d/

#Install MariaDB Server
sudo dnf install -y MariaDB-server

# Enable as well as Start the mariadb service
sudo systemctl enable --now mariadb

## Resetting root password, removing database called 'test' and any related tables to it
sudo mariadb <<_EOF_
ALTER USER root@localhost IDENTIFIED VIA mysql_native_password USING PASSWORD("$_root_new_passwd");
DROP DATABASE IF EXISTS test;
DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%';
FLUSH PRIVILEGES;
FLUSH PRIVILEGES;
_EOF_
###
echo "Installation finished"

Step 2: Change the permission of the script file.

chmod +x install_mariadb_10.04_centos8.sh

Step 3: Now run the script. You should give a new root password of MariaDB in first argument.

sh install_mariadb_10.04_centos8.sh MyNewRootPassword

Summary of install_mariadb_10.04_centos8.sh bash script

1. It create the mariadb yum repo file.
2. Then install the mariadb server by dnf command.
3. Then it enable and start the mariadb service.
4. At the end, it reset the root password. By default it is blank root password. As well as remove the 'test' database.

Login to MariaDB Server

Run the following command to login as root user in MariaDB server. Give the password which you have used in Step 3.

mariadb -u root -p

OR

mysql -u root -p

Output From Our System:

[sharad@mariadb01 ~]$ mariadb -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 10.4.13-MariaDB MariaDB Server

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

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

MariaDB [(none)]> 

Manage MariaDB Service

1. Check status of MariaDB service.

sudo systemctl status mariadb

2. Start the MariaDB service.

sudo systemctl start mariadb

3. Stop the MariaDB service.

sudo systemctl stop mariadb

4. Re-start the MariaDB service.

sudo systemctl restart mariadb

5. Enable the MariaDB service. It start the service at system booting time.

sudo systemctl enable mariadb

6. Disable the MariaDB service. Means do not let service to start at booting time.

sudo systemctl disable mariadb

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. How to upgrade Mariadb 5.5 to Mariadb 10.0 on CentOS 7 / RHEL 7
  2. Install MariaDB Server 10 on CentOS 7 and RHEL 7 by using yum
  3. Install MariaDB Server on CentOS 7 / RHEL 7
  4. Install MariaDB Server 10.0 on Ubuntu 14.04 LTS ( Trusty Tahr )
  5. Install and configure Varnish Cache server on CentOS/RHEL 6.x
  6. Install and configure transparent squid proxy server : RHEL/CentOS 6.x
  7. Install pagespeed module ( mod_pagespeed ) on Apache Web Server : CentOS / RHEL
  8. How to install MySQL Server 5.6 on CentOS 7 / RHEL 7
  9. How to install redis server on CentOS 7 / RHEL 7
  10. Install Telnet Server on CentOS 7 / RHEL 7

Filed Under: Linux Tagged With: bash script, MariaDB Server

Reader Interactions

Leave a Reply Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Linux Commands

6 df Command Examples To Check Mounted Filesystem On Linux

How to test rpm package before installation

tr command to convert lines to space , tab and vertical tab

How to make rm -fr command to be interactive

How to print particular line number by using sed command

Find exit status code of last executed command on Linux and Unix

awk command to search keyword or strings in file

Explore 70+ Articles On Linux Commands

Always Useful Tips And Tricks

fatal error: error writing to /tmp/ccwAjc9Z.s: No space left on device

How to put slider shortcode only in home page in WordPress

Convert hyphen to underscore in between all filenames shell script

GNU Screen

linux release renew dhcp assigned ip address

Convert video file into gif file through command line in linux

Recover Linux Grub Password in linux rescue mode CentOS/Red Hat

Explore 90+ Article On "Linux Tips And Tricks"

You Might Like These Articles!

Internal External Command

What is Linux/Unix Internal And External Command

Linux basic command

Linux Basic Commands For Every Beginner

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Nginx

How To Install Nginx On Ubuntu 22.04 LTS

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

Copyright © 2023 ยท
The material in this site cannot be republished either online or offline, without our permission but Schools and Colleges can do in their Private Network
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy