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.
How to install MariaDB on CentOS 8
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
- Installing the MariaDB on CentOS 8, type:
sudo yum install mariadb-server
- Securing the MariaDB server in CentOS 8, run:
- 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
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
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.
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
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.
How to add database on the MariaDB server
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:
Quit from MariaDB:
How to connect to the MariaDB database nixcraft using vivek account
$ mysql -u tristan -p'secretePasswordHere' blog1
$ mysql -u tristan -p blog1
For further information see:
- Create a MySQL Database, Tables and Insert Data
- Mysql User Creation: Setting Up a New MySQL User Account
- How to delete or remove a MySQL/MariaDB user account on Linux/Unix
- How Do I Enable Remote Access To MySQL Database Server?
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.