MariaDB is an open-source relational database management system and a drop replacement of MySQL DB server. It is a fork of MySQL and managed by the original MySQL developers. MariaDB is a multi-user, multi-threaded SQL database server. In this article you will learn how to install and secure MariaDB on CentOS 8 server.
Install MariaDB on CentOS 8
MariaDB 10.3 version is available in the CentOS 8 repositories while writing this article so we will install it.
You should login using root or user with sudo privileges to install MariaDB 10.3 on CentOS 8 system. Run the below command to install:
sudo dnf install @mariadb
It will install MariaDB server and all dependencies.
You should start MariaDB service and enable it for automatically start on boot using below command:
sudo systemctl enable --now mariadb
You can verify that MariaDB server is running or not by typing:
sudo systemctl status mariadb
It should show output as given below:
● mariadb.service - MariaDB 10.3 database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled) Active: active (running) since Sun 2020-02-02 20:15:06 UTC; 15s ago ...
You can increase the security of MariaDB server by running default script named
mysql_secure_installation. Which performs security-related operations and remove anonymous user, restrict remote root access and remove test databases. Run the below command:
At first, it will prompt you to enter root user password. Next, it will ask you weather you want to change or set password for root. Press y and hit Enter key. After that it will prompt series of questions, Press y and hit Enter to accept the defaults for all the subsequent questions.
It’s done! You have installed and secured MariaDB on your CentOS 8 server, and you can use it.
Connect to MariaDB from the command line
You can connect MariaDB server through the terminal as the root account by typing:
mysql -u root -p
It will prompt you to enter root user password, Enter root user password. On successful it will show output as following:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 18
Server version: 10.3.11-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.
You have successfully installed and secured MariaDB on a CentOS 8 server, and connect to MariaDB server using command line.
If you have specific requirement of MySQL instead of MariaDB, read How to Install MySQL on CentOS 8 tutorial.
If you have any question, feel free to comment below.