How To Install MariaDB on CentOS 8

ADVERTISEMENTS



How to install MariaDB on CentOS 8

I am a new to MariaDB server and CentOS 8 sysadmin. How do I install MariaDB on CentOS 8 Linux server using the yum command Introduction – MariaDB is a free and open-source database management system and acts as a drop replacement for the Oracle MySQL DB server. It is a community-driven and developed branch of Oracle MySQL server. MariaDB is a multi-user, multi-threaded SQL database server. This page explains how to install the latest stable version of MariaDB on CentOS 8 server.

The procedure to install MariaDB on a CentOS Enterprise Linux 8 is as follows:

Open the terminal application. Another option is to log in using the ssh command ssh user@centos-8-server-ip Installing the MariaDB on CentOS 8, type:

sudo yum install mariadb-server Securing the MariaDB server in CentOS 8, run:

sudo mysql_secure_installation Finally test your installation by running:

mysql -u root -p

Let us see all steps and commands in details.

Installing MariaDB on CentOS 8 using the yum command

One can search for MariaDB package using the following syntax:

sudo yum search mariadb



Want to find out MariaDB server version? Try:

sudo yum info mariadb

Sample outputs:

Last metadata expiration check: 0 : 37 : 22 ago on Tuesday 01 October 2019 02: 35 : 21 PM UTC. Installed Packages Name : mariadb Epoch : 3 Version : 10.3.11 Release : 2 .module_el8.0.0+ 35 +6f2527ed Arch : x86_64 Size : 38 M Source : mariadb-10.3.11- 2 .module_el8.0.0+ 35 +6f2527ed.src.rpm Repo : @System From repo : AppStream Summary : A very fast and robust SQL database server URL : http://mariadb.org License : GPLv2 with exceptions and LGPLv2 and BSD. Description : MariaDB is a community developed branch of MySQL - a multi-user, multi-threaded Last metadata expiration check: 0:37:22 ago on Tuesday 01 October 2019 02:35:21 PM UTC. Installed Packages Name : mariadb Epoch : 3 Version : 10.3.11 Release : 2.module_el8.0.0+35+6f2527ed Arch : x86_64 Size : 38 M Source : mariadb-10.3.11-2.module_el8.0.0+35+6f2527ed.src.rpm Repo : @System From repo : AppStream Summary : A very fast and robust SQL database server URL : http://mariadb.org License : GPLv2 with exceptions and LGPLv2 and BSD. Description : MariaDB is a community developed branch of MySQL - a multi-user, multi-threaded

Installation

Next type the following yum command to MariaDB version 10.3.11 on CentOS 8:

$ sudo yum install mariadb-server



How to enable mariadb.service at CentOS 8 server boot time

Run the following systemctl command:

$ sudo systemctl enable mariadb.service

Created symlink /etc/systemd/system/mysql.service ? /usr/lib/systemd/system/mariadb.service. Created symlink /etc/systemd/system/mysqld.service ? /usr/lib/systemd/system/mariadb.service. Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service ? /usr/lib/systemd/system/mariadb.service. Created symlink /etc/systemd/system/mysql.service ? /usr/lib/systemd/system/mariadb.service. Created symlink /etc/systemd/system/mysqld.service ? /usr/lib/systemd/system/mariadb.service. Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service ? /usr/lib/systemd/system/mariadb.service.

How to start/stop/restart mariadb.service on CentOS 8

Again use the following syntax:

$ sudo systemctl stop mariadb.service

$ sudo systemctl start mariadb.service

$ sudo systemctl restart mariadb.service

$ sudo systemctl status mariadb.service



How to secure the MariaDB Server on CentOS 8

You must secure the MariaDB server by running the following command for production use:

$ sudo mysql_secure_installation



How do I log in to the MariaDB server?

Use the mysql command as follows:

$ mysql -u root -p



How to add database on the MariaDB server

Above commands indicates the installation has been successful on CentOS 8 server or VM. You can now add users and create databases for your applications written in PHP, Perl, Python and more.

First, log in as root user:

$ mysql -u root -p mysql

Create a new MariaDB database called blog1. Type the following command at MariaDB> prompt:

CREATE DATABASE blog1;

How to add users on the MariaDB server

Create a new user called tristan for database called blog1 (feel free to replace username and secretePasswordHere with actual password):

GRANT ALL ON blog1.* TO tristan@localhost IDENTIFIED BY 'secretePasswordHere';

List all database:

show databases;

Quit from MariaDB:

quit



How to connect to the MariaDB database nixcraft using vivek account

$ mysql -u tristan -p'secretePasswordHere' blog1

OR

$ mysql -u tristan -p blog1



For further information see:

Conclusion

You completed and secured MariaDB on CentOS 8 server. Further, you learned how to create users and databases on the MariaDB server. For more info see MariaDB site here and recommended MariaDB books here.

