How to install MariaDB on Rocky Linux 8

Share on Social Media

Learn how to install MariaDB on Rocky Linux 8 with our straightforward guide. Follow step-by-step instructions to set up this MySQL fork, a powerful and reliable open-source relational database management system, on your Linux server. #centlinux #linux #mysql

What is MariaDB?

MariaDB is an open-source relational database management system (RDBMS) and a drop-in replacement for MySQL. It was created by the original developers of MySQL due to concerns over Oracle’s acquisition of MySQL AB. MariaDB retains compatibility with MySQL while offering additional features, performance improvements, and enhanced security.

Key features of MariaDB include:

  1. Compatibility: MariaDB maintains compatibility with MySQL, ensuring that existing MySQL applications can easily transition to MariaDB without modification.
  2. Performance: MariaDB includes optimizations and enhancements that can improve database performance compared to MySQL, such as a new storage engine (Aria) and thread pooling.
  3. High Availability: MariaDB offers features like replication, clustering, and automatic failover to ensure high availability and reliability of database services.
  4. Security: MariaDB includes security enhancements such as database encryption, role-based access control (RBAC), and improved authentication mechanisms to protect data integrity and confidentiality.
  5. Scalability: MariaDB supports scalability through features like parallel replication, sharding, and multi-master replication, allowing it to handle large-scale deployments and high-volume workloads.
  6. Community-driven Development: MariaDB is developed and maintained by a vibrant community of contributors, ensuring ongoing development, support, and innovation.

Overall, MariaDB is a powerful and feature-rich alternative to MySQL, suitable for a wide range of applications from small-scale projects to large-scale enterprise deployments.

How to install MariaDB on Rocky Linux 8
How to install MariaDB on Rocky Linux 8

MariaDB vs MySQL: Key Differences

Both MariaDB and MySQL are popular relational databases, but they differ in licensing, performance, and community support. Here’s a simplified comparison:


1. Origins & Licensing

  • MySQL: Owned by Oracle, offering both open-source (GPL) and proprietary versions. Some users worry about Oracle’s control.
  • MariaDB: A fork of MySQL created by its original developers. Fully open-source (GPL) with no proprietary restrictions.

Key Point: MariaDB is more community-driven, while MySQL has corporate backing.


2. Performance & Features

  • MySQL: Stable and reliable, with strong enterprise support. Uses InnoDB as the default storage engine.
  • MariaDB: Often faster in benchmarks, with extra engines like AriaColumnStore, and RocksDB. Supports Galera Cluster for multi-master replication.

Key Point: MariaDB offers more features and better performance in some cases, while MySQL focuses on stability.


3. Security & Updates

  • MySQL: Enterprise users get advanced security features, but community updates may lag.
  • MariaDB: More frequent open-source security patches and built-in encryption options.

Key Point: MariaDB is often preferred for security-conscious open-source projects.


4. Which One Should You Use?

  • Choose MySQL if: You need Oracle’s enterprise support or work with legacy systems.
  • Choose MariaDB if: You want better performance, more features, and full open-source freedom.

Final Verdict:

  • For most new projects → MariaDB (faster, more features).
  • For corporate environments → MySQL (enterprise support).

Environment Specification

We are using a minimal Rocky Linux 8 virtual machine with following specifications.

  • CPU – 3.4 Ghz (2 cores)
  • Memory – 2 GB
  • Storage – 20 GB
  • Operating System – Rocky Linux 8.5 (Green Obsidian)
  • Hostname – mariadb-01.centlinux.com
  • IP Address – 192.168.116.128 /24

Recommended Training: The Ultimate MySQL Bootcamp: Go from SQL Beginner to Expert from Colt Steele

1187016 51b3
show?id=oLRJ54lcVEg&bids=1628165

Update Your Rocky Linux Server

By using a SSH client, connect with your Linux server as root user.

Build yum cache of installed repositories.

dnf makecache

Execute following command to update software packages in your Linux server.

dnf update -y

Check the Linux Operating System and Kernel versions as follows.

cat /etc/rocky-release && uname -r

Output:

Rocky Linux release 8.5 (Green Obsidian)
4.18.0-348.20.1.el8_5.x86_64

Install MariaDB on Rocky Linux 8

Get the list of MariaDB modules, that are available in standard yum repositories.

dnf module list mariadb

Output:

Last metadata expiration check: 0:02:47 ago on Mon 04 Apr 2022 08:05:18 PM PKT.
Rocky Linux 8 - AppStream
Name Stream Profiles Summary
mariadb 10.3 [d] client, galera, server [d] MariaDB Module
mariadb 10.5 client, galera, server [d] MariaDB Module

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

You can see that, our required MariaDB Server 10.8 is not available in Rocky Linux yum repositories.

Therefore, you have to install MariaDB Official Repository on your Linux server.

Visit MariaDB Official website and select your Linux operating system to generate a yum repo for your machine.

MariaDB Downloads
MariaDB Downloads

Create a yum repo file by using vim text editor.

vi /etc/yum.repos.d/MariaDB.repo

Copy and paste the generated yum repo into this file.

# MariaDB 10.8 [RC] CentOS repository list - created 2022-04-04 14:48 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB 
baseurl = https://mirrors.gigenet.com/mariadb/yum/10.8/centos8-amd64 
module_hotfixes=1 
gpgkey=https://mirrors.gigenet.com/mariadb/yum/RPM-GPG-KEY-MariaDB 
gpgcheck=1

Save and exit.

Build cache for newly installed yum repositories.

dnf makecache

Output:

MariaDB                                          57 kB/s | 201 kB     00:03
Rocky Linux 8 - AppStream 3.5 kB/s | 4.8 kB 00:01
Rocky Linux 8 - BaseOS 2.3 kB/s | 4.3 kB 00:01
Rocky Linux 8 - Extras 2.6 kB/s | 3.5 kB 00:01
Metadata cache created.

Now you can install MariaDB on Rocky Linux by executing following Linux command.

dnf install -y mariadb-server

Enable and start MariaDB Service.

systemctl enable --now mariadb.service

Check the status of MariaDB service.

systemctl status mariadb.service

Output:

● mariadb.service - MariaDB 10.8.2 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor pre>
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: active (running) since Mon 2022-04-04 20:18:03 PKT; 10min ago
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 4728 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 8 (limit: 5808)
Memory: 261.1M
CGroup: /system.slice/mariadb.service
└─4728 /usr/sbin/mariadbd

Apr 04 20:18:03 mariadb-01.centlinux.com mariadbd[4728]: 2022-04-04 20:18:03 0 >
Apr 04 20:18:03 mariadb-01.centlinux.com mariadbd[4728]: 2022-04-04 20:18:03 0 >
Apr 04 20:18:03 mariadb-01.centlinux.com mariadbd[4728]: Version: '10.8.2-Maria>

Configure initial settings of your MariaDB server.

mariadb-secure-installation

Output:

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] n
... skipping.

You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] n
... skipping.

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
... Success!

Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Connect to your MariaDB Server by using mysql command.

mysql -u root -p

Display list of available databases.

show databases;

Output:

+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.071 sec)

You have successfully install MariaDB on Rocky Linux operating system.

Configure Linux Firewall

If you plan to access your MariaDB database server from network, then you have enable the MariaDB service in your Linux Firewall.

firewall-cmd --permanent --add-service=mysql
firewall-cmd --reload

Frequently Asked Questions (FAQs)

1. What is the easiest way to install MariaDB on Rocky Linux 8?

Use dnf to install MariaDB and start it automatically:

sudo dnf install mariadb-server mariadb -y  
sudo systemctl enable --now mariadb  

2. How do I check if MariaDB is running properly?

Verify the service status with:

sudo systemctl status mariadb  

(If active, you should see active (running) in green.)

3. How do I set a root password for MariaDB?

Run the security script and follow the prompts:

sudo mysql_secure_installation  

(You’ll be asked to set a password, remove anonymous users, disable remote root login, and more.)

4. How do I create a new MariaDB user and database?

Log in to MariaDB (sudo mysql -u root -p), then run:

CREATE DATABASE mydb;  
CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'password';  
GRANT ALL PRIVILEGES ON mydb.* TO 'myuser'@'localhost';  
FLUSH PRIVILEGES;  

5. How do I allow remote connections to MariaDB?

Edit /etc/my.cnf.d/mariadb-server.cnf and add:

[mysqld]  
bind-address = 0.0.0.0  

Restart MariaDB (sudo systemctl restart mariadb) and configure the firewall.

Final Thoughts

Installing MariaDB on Rocky Linux 8 provides you with a robust and reliable open-source database management system for your server. With our comprehensive guide, you can easily set up MariaDB and leverage its powerful features to manage your data effectively.

Your Linux servers deserve expert care! I provide reliable management and optimization services tailored to your needs. Discover how I can help on Fiverr!

Looking for something?

Leave a Reply