• 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

Install MariaDB Server on CentOS 7 / RHEL 7

July 31, 2014 by Sharad Chhetri 2 Comments

In this tutorial we will learn, how to install MariaDB Server on CentOS 7 / RHEL 7 . Before the stable release of RHEL 7, it was confirmed the MariaDB will be default database. This is one of the major changes we have observed in this RHEL 7/CentOS 7 stable release.
Whereas MySQL server still available and can be installed on RHEL 7 /CentOS 7 . (Read this How To)

Although at the time of writing this post, MariaDB 10.0.12 Stable release is available (Dated on 2014-06-16) , yet we will install it by simply using yum command from default yum repo.

Install MariaDB Server

To install MariaDB Server and MariaDB client. Use the below given command

yum install mariadb-server mariadb

After installation, we have checked the version of MariaDB Server. Given below is the detail
Server version: 5.5.37-MariaDB MariaDB Server

We queried the list of rpm packages related to MariaDB and given below is the result

[root@localhost ~]# rpm -qa|grep -i maria
mariadb-5.5.37-1.el7_0.x86_64
mariadb-server-5.5.37-1.el7_0.x86_64
mariadb-libs-5.5.37-1.el7_0.x86_64
[root@localhost ~]#

Now start the MariaDB Server . Bydefault it is not started.

systemctl start mariadb.service

Start/Stop/Restart/Status MariaDB Server

To start MariaDB Server

systemctl start mariadb.service

To stop MariaDB Server

systemctl stop mariadb.service

To restart MariaDB Server

systemctl restart mariadb.service

To get status of MariaDB Server

systemctl status mariadb.service

Enable MariaDB Server at booting time

systemctl enable mariadb.service

Disable MariaDB Server at booting time

systemctl disable mariadb.service

To know active status of MariaDB Server.

systemctl is-active mariadb.service

Reset the blank root password of MariaDB Server [Very Important]

After fresh installation of MariaDB Server, the database root user’s password is blank.
For security reason it is very important to reset the root’s blank password.

See below given reference, where without database root password we are able to login

[root@localhost ~]# mysql -u root
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 3
Server version: 5.5.37-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

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

MariaDB [(none)]> 

Method 1 : By using mysql_secure_installation command

Simply run the command mysql_secure_installation on your terminal. And follow the instruction. In beginning it will ask you to reset root password. We generally recommend this easy command after doing fresh installation of MariaDB Server.

The below given is reference from our server

[root@localhost ~]# mysql_secure_installation 
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
[root@localhost ~]# 

Method 2: Reset root password by login into MariaDB Server

In this method we will login into MariaDB Server and then reset the root password.

mysql -u root

You will get the Mariadb prompt like this: MariaDB [(none)]>

Now run below given command in MariaDB server to reset root password.

use mysql;
update user set password=PASSWORD("GIVE-NEW-ROOT-PASSWORD") where User='root';
flush privileges;
quit

Given below is reference from our server

[root@localhost ~]# mysql -u root 
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 10
Server version: 5.5.37-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

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

MariaDB [(none)]> 
MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> update user set password=PASSWORD("GIVE-NEW-ROOT-PASSWORD") where User='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0

MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> quit
Bye
[root@localhost ~]# 
[root@localhost ~]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 11
Server version: 5.5.37-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

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

MariaDB [(none)]> Ctrl-C -- exit!
Aborted
[root@localhost ~]#

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. How to install Mariadb 10.4 server on CentOS 8 / RHEL 8
  4. Install MariaDB Server 10.0 on Ubuntu 14.04 LTS ( Trusty Tahr )
  5. Install Mariadb 5.5 on Ubuntu 12.04 LTS
  6. Install and configure Varnish Cache server on CentOS/RHEL 6.x
  7. Install and configure transparent squid proxy server : RHEL/CentOS 6.x
  8. Install pagespeed module ( mod_pagespeed ) on Apache Web Server : CentOS / RHEL
  9. How to install MySQL Server 5.6 on CentOS 7 / RHEL 7
  10. How to install redis server on CentOS 7 / RHEL 7

Filed Under: Database Server, Linux Tagged With: MariaDB

Reader Interactions

Comments

  1. Shailesh says

    April 14, 2017 at 5:40 pm

    Very useful blog!

  2. Bharath says

    February 10, 2016 at 6:52 am

    Very useful article!

Leave a 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

Linux Commands

How to rename and move the directory and files in linux

Learn Linux Date Command With Examples

FAQ on CentOS 7 / RHEL 7 : Alternate of ifconfig command

Useful tail command with examples in Linux/Unix

awk command to print columns from file

create a system account below uid 500 on RHEL/CentOS/Scientific Linux

Search Keyword In Man Page Like We Search In vi / vim Editor

Explore 70+ Articles On Linux Commands

Always Useful Tips And Tricks

How To Get SSH Public Key Fingerprint Information

How to convert float to integer number

Change the default port number of ssh server

Replace keyword with its filename without extension : bash script

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

linux release renew dhcp assigned ip address

How to install pam_mysql in CentOS or 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 With Examples 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