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 commandssh 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
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.
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
Securing the MariaDB Server on CentOS 8
How do I log in to the MariaDB server?
Use the mysql command as follows:
$ mysql -u root -p
Testing the MariaDB server installation
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:
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:
- 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?
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.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 0 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |