How to Install MariaDB Server in Rocky Linux

The name MariaDB needs no introduction as its track record on numerous web-based and desktop-based projects speak for itself. The maturity in MariaDB’s performance delivery also makes it an ideal candidate for data analytics due to its columnar database solution. Therefore, if you are aiming for large-scale real-time analytics, MariaDB has your back.

Rocky Linux being a Red Hat Enterprise downstream as a result of it being Centos’ fork makes it an ideal server environment to run web-based projects that require the reputation of MariaDB database management prowess.

Prerequisite

On the Rocky Linux operating system you are using, make sure you have full administrative privileges i.e. be a sudoer/root user on the Rocky Linux system.

Installing MariaDB in Rocky Linux

An updated system is optimized for better performance which also affects the software packages installed on that system.

$ sudo dnf update && sudo dnf upgrade -y

Next, install MariaDB database software on your Rocky Linux system.

$ sudo dnf install mariadb-server -y 
Install MariaDB in Rocky Linux
Install MariaDB in Rocky Linux

The database software installation process should take a minute or two to complete.

Once installed, make sure to start and enable database management software, so that it will keep on running even after a system reboot/shutdown.

$ sudo systemctl start mariadb
$ sudo systemctl enable mariadb
$ sudo systemctl status mariadb
Check MariaDB in Rocky Linux
Check MariaDB in Rocky Linux

Securing MariaDB in Rocky Linux

Next, you need to secure the MariaDB installation by setting a strong root database user password, removing anonymous DB users, and disallowing remote login.

$ sudo mysql_secure_installation 
Secure MariaDB in Rocky Linux
Secure MariaDB in Rocky Linux

You can now try to access the database with the set root user password.

$ mysql -u root -p

Create a database user, database, and assign control over the created database to the user.

MariaDB [(none)]> CREATE USER [email protected] IDENTIFIED BY "Your_preferred_db_user_password";
MariaDB [(none)]> CREATE DATABASE linuxshelltips_db;
MariaDB [(none)]> GRANT ALL ON linuxshelltips_db.* TO [email protected]; 
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit 
Create MySQL User in Rocky Linux
Create MySQL User in Rocky Linux

We have successfully installed, configured, and demonstrated the implementation of some SQL commands under MariaDB database management software. Your Rocky Linux system is now ready to embrace database-driven web-based projects.

Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.