In this tutorial/article, we will illustrate to you how to install and get started with MariaDB on Centos 8.
Steps to install MariaDB on Centos 8
First, make sure you have Centos 8 installed in your system. Now, open Terminal in Centos 8. Another choice is to sign in using the user@centos-8-server-ip ssh commandssh. Then go through the following three steps:
- MariaDB Installation on Centos 8
- Securing the Centos 8 MariaDB server
- Test the Installation
Let us see in detail all the steps and commands.
MariaDB installation on Centos 8
Use the following command to search for the MariaDB package:
After that, use the following command to look out for the MariaDB server version:
The first step of the installation is to add the following ‘dnf’ or ‘yum’ command as a root user:
You will be asked to enter your current account password to proceed with the installation.
After that, you will be questioned to affirm your action to proceed further. Type ‘y’ and then tap Enter to continue as shown. The @mariadb package will load the MariaDB server and all its plugins.
When the setup is complete, start the MariaDB service and enable it to begin the boot process instantly by typing the appended below command:
To confirm that the MariaDB service is working, check the status of the system using the following command:
The output should demonstrate that the system is running and activated, as you can see in the affixed image.
Securing the Centos 8 MariaDB server
The MariaDB kit provides a script named MySQL secure installation that executes many security-related functions and determines the root password. Use this instruction to execute the protection script:
You will be asked to enter your current account password to proceed after that. You will then be asked to place a password for the root account of MariaDB that has not yet been set, so you have to press ENTER as suggested. Note that it is for the root account of the database, not really for the root account of your Centos server itself. To set a passcode for the root database user, tap ‘y’ and then ENTER, and after that, go through all the instructions.
You have to accept all the safety recommendations by tapping ‘y’ and then ENTER after updating the password. It will delete anonymous users, disable remote root login, erase the test database, and load up the tables of privileges.
Now, on your CentOS 8, you had already configured and secured MariaDB, and it is ready to be used.
Test the Installation
You can check your installation and configuration, also get details about all this by communicating with the mysqladmin program, a client that allows you to operate administrative instructions. To link via the console to the MariaDB server as the root account, type the following instruction:
You may be asked for a password (-p), and the version will be shown. Output similar to this should be shown, as seen in the appended image.
The above instructions suggest that the installation was active on the server. You can now connect users and construct databases for your applications.
Sign in as the root user first by using the below-mentioned command. It will ask you to type your password.
Add a new Database
Build a new database for MariaDB, named test. At the MariaDB command prompt, run the following instruction:
CREATE DATABASE test
Note: You can set the name of the database as per your choice.
Add new User
Build a new user for the test database named ‘student’. You can feel free to substitute secretePasswordHere with the real password you want to add. Try this command for adding a new user:
Note: You can set the name of a new user in the database as per your choice.
You can also check the list of all databases present in MariaDB using the following command:
You can also exit MariaDB using a simple ‘quit’ command as follows:
Connect to MariaDB database
You can easily connect to the MariaDB database by executing one of the following commands:
This guide shows you the installation process and usage of MariaDB on Centos 8 and its connection via the command prompt to the MariaDB server, as well as adding databases and users to it. Your MariaDB server is ready and fully operational. You may now start building new databases and users by connecting to the MariaDB shell. Centos 8 also provide MySQL 8.0. If you like to install MySQL rather than MariaDB, you may also do so. Now, you are in a position, by walking through this tutorial, to install and get started with MariaDB on Centos 8.