Learn how to install MariaDB on AlmaLinux 10 and configure the database server with this step-by-step guide. Get your database server up and running in minutes—perfect for sysadmins and developers! #centlinux #mariadb #linux
Table of Contents
Introduction
What is MariaDB?
MariaDB is a popular open-source relational database management system (RDBMS) that originated as a fork of MySQL. It was created by the original developers of MySQL after Oracle acquired it. The main goal? To keep MariaDB free and open, and to maintain compatibility with MySQL while adding new features and performance improvements.
It’s widely used in web hosting environments, cloud platforms, and enterprise systems. MariaDB is known for its reliability, ease of use, and performance optimization. Whether you’re managing a small blog or running complex business applications, MariaDB fits the bill.
Key features include:
- Support for ACID transactions
- Full SQL compliance
- Compatibility with MySQL clients and connectors
- Advanced replication and clustering options
- Rich security features

Overview of AlmaLinux 10
AlmaLinux 10 is a stable, community-driven enterprise Linux distribution that is 1:1 binary compatible with RHEL (Red Hat Enterprise Linux). After CentOS shifted to a rolling-release model, AlmaLinux emerged as a leading alternative for businesses and sysadmins who need a free, stable OS with long-term support.
Why is AlmaLinux great for databases? Because it offers:
- Stability and long-term support
- SELinux for enhanced security
- Great community and documentation
- Excellent performance on servers
AlmaLinux 10 is designed for production environments, making it perfect for setting up something mission-critical like MariaDB.
Why Install MariaDB on AlmaLinux?
Combining MariaDB with AlmaLinux gives you a secure, high-performance, and reliable database stack. Here’s why it’s a smart move:
- Security: SELinux and firewall support
- Compatibility: MariaDB integrates seamlessly with PHP, Python, and other programming environments
- Performance: Optimized kernel and I/O handling on AlmaLinux
- Stability: Enterprise-grade updates and reliability
- Cost-effectiveness: 100% free and open-source
Preparing Your AlmaLinux 10 System
Before you jump into installing MariaDB, it’s important to prep your system. Think of it like cleaning the kitchen before you cook a feast—less mess, more success.
System Requirements
Here’s what you’ll need:
- AlmaLinux 10 installed
- A user with sudo privileges
- At least 1 GB of RAM (2 GB or more recommended)
- Internet access to install packages
Although MariaDB isn’t too demanding, ensuring enough memory and CPU power is vital if you expect heavy usage or need to support multiple applications.
You can check your system’s memory and CPU with:
free -h
lscpu
Make sure your system meets the baseline before moving forward.
Recommended Training: The Ultimate MySQL Bootcamp: Go from SQL Beginner to Expert from Colt Steele

Updating the System
Always start by updating your system packages. This prevents conflicts and ensures compatibility.
Run:
sudo dnf update -y
sudo dnf upgrade -y
This brings all packages to their latest stable versions and applies any necessary security patches. You don’t want to install MariaDB on a buggy or outdated system, right?
After updating, it’s a good idea to reboot:
sudo reboot
Installing EPEL Repository (if required)
While MariaDB itself doesn’t need EPEL (Extra Packages for Enterprise Linux), some tools and extensions that support it might.
To be safe:
sudo dnf install epel-release -y
This gives you access to additional software packages and tools that might be useful later (like performance monitoring, backups, etc.).
Linux Bible
$34.99 (as of July 8, 2025 20:56 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Installing MariaDB on AlmaLinux 10
Now for the fun part—getting MariaDB onto your system.
MariaDB Installation Using DNF
First, check if MariaDB is already available via AlmaLinux repositories:
sudo dnf module list mariadb
By default, AlmaLinux 10 comes with the MariaDB 10.5 module, but if you want the latest stable version (like 10.11 or higher), you should use the official MariaDB repository.
Create the MariaDB repo:
sudo tee /etc/yum.repos.d/MariaDB.repo << EOF
[mariadb]
name = MariaDB
baseurl = ttps://mirror.mariadb.org/yum/10.11/rhel/10/x86_64/
gpgkey=https://mirror.mariadb.org/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF
Install MariaDB server:
sudo dnf install MariaDB-server -y
Confirm the version:
mysql --version
You should now see something like
mysql Ver 15.1 Distrib 10.11.4-MariaDB
Starting and Enabling the MariaDB Service
Let’s get MariaDB running:
sudo systemctl start mariadb
sudo systemctl enable mariadb
This ensures MariaDB starts automatically every time your system boots.
You can confirm it’s running with:
sudo systemctl status mariadb
Look for “active (running)”—that’s your green light.
Verifying the MariaDB Installation
Just to be thorough, let’s log into the MariaDB shell:
sudo mysql
If you see the MariaDB prompt (MariaDB [(none)]>
), you’re in!
Exit by typing:
exit;
At this point, MariaDB is installed and running on AlmaLinux 10. Next, let’s make it secure.
Securing MariaDB Server
Now that your database is live, it’s time to lock it down and remove potential vulnerabilities.
Running the mysql_secure_installation Script
MariaDB comes with a handy script to secure the default installation:
sudo mysql_secure_installation
You’ll be asked a series of questions:
- Set root password? Yes
- Remove anonymous users? Yes
- Disallow root login remotely? Yes
- Remove test database? Yes
- Reload privilege tables? Yes
This step closes common loopholes and prepares MariaDB for production use.
Configuring Root Password and Removing Test Databases
During the secure installation process, you’ll set a root password. Don’t skip this. The default setup has no password for the root user, which is a big no-no.
Removing the test database is equally important—it’s open to all users and can be exploited if left in place.
Managing User Privileges
Once you’ve secured the root account, the next step is to control who can do what in your database.
Log in:
sudo mysql -u root -p
To create a new user with restricted access:
CREATE USER 'appuser'@'localhost' IDENTIFIED BY 'StrongPass123!';
GRANT ALL PRIVILEGES ON mydatabase.* TO 'appuser'@'localhost';
FLUSH PRIVILEGES;
Always follow the principle of least privilege. Don’t give root-level access unless absolutely necessary.
65W Surface Pro Laptop Charger for Microsoft Surface Pro 10, 9, 8, 7+, 7, 6, 5, 4, 3, X, Windows Surface Laptop 6, 5, 4, 3, 2, 1, Surface Go Tablet, Surface Book 3, 2, 1, Support 44W, 36W, LED, 10FT
$22.94 (as of July 8, 2025 20:58 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Configuring MariaDB for Remote Access
MariaDB by default only listens to localhost (127.0.0.1) for security reasons. If you want to connect remotely—say, from another server or through a GUI like DBeaver or HeidiSQL—you’ll need to tweak a few settings.
Editing MariaDB Configuration File
The configuration file responsible for MariaDB’s networking settings is usually located at:
/etc/my.cnf.d/mariadb-server.cnf
Open it with your favorite text editor:
sudo nano /etc/my.cnf.d/mariadb-server.cnf
Look for the following line under [mysqld]
:
bind-address=127.0.0.1
Change it to:
bind-address=0.0.0.0
This tells MariaDB to accept connections from any IP address. If you want to limit access to a specific IP (e.g., 192.168.1.10), use that instead of 0.0.0.0
.
Save the file and exit, then restart MariaDB:
sudo systemctl restart mariadb
Opening Firewall Ports
Next, allow traffic through the firewall on port 3306 (the default MariaDB port):
sudo firewall-cmd --permanent --add-port=3306/tcp
sudo firewall-cmd --reload
This step is vital—without it, remote connections will be blocked even if MariaDB is listening.
Creating a Remote User with Proper Privileges
You’ll also need to create a user that can connect from a remote location:
CREATE USER 'remoteuser'@'%' IDENTIFIED BY 'RemotePass123!';
GRANT ALL PRIVILEGES ON *.* TO 'remoteuser'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
This user can now connect to your MariaDB server remotely using tools or applications, as long as the firewall and bind settings are correct.
Caution: Allowing @'%'
access is a broad permission. For enhanced security, specify the remote IP instead, e.g., 'remoteuser'@'192.168.1.100'
.
Managing the MariaDB Service
Once MariaDB is up and running, knowing how to manage the service is crucial for maintenance, troubleshooting, and uptime.
Checking the Status of the MariaDB Service
You can check whether MariaDB is active using:
sudo systemctl status mariadb
You should see output indicating it’s active (running). If not, use the logs to identify what went wrong:
journalctl -xeu mariadb
Enabling MariaDB to Start at Boot
To ensure MariaDB starts every time your server boots, use:
sudo systemctl enable mariadb
This adds MariaDB to the boot process. Skipping this step could mean unexpected outages after reboots.
To double-check:
sudo systemctl is-enabled mariadb
It should return enabled
.
Restarting and Reloading the Service
You’ll often need to restart MariaDB after making configuration changes. Here’s how:
sudo systemctl restart mariadb
If you only want to reload the settings without restarting the entire service:
sudo systemctl reload mariadb
This is faster and doesn’t interrupt active connections, making it ideal for minor tweaks.
Basic MariaDB Usage
Once the system is secured and ready, it’s time to interact with MariaDB and get a feel for using it.
Logging into the MariaDB Shell
To access the MariaDB shell:
sudo mysql -u root -p
After entering your password, you’ll be in the MariaDB command-line interface, where you can run SQL queries.
Example:
SHOW DATABASES;
This command displays all current databases.
To exit:
exit;
Creating a New Database and User
Let’s say you’re setting up a database for a web app. Here’s how you can create a database and user:
CREATE DATABASE myappdb;
CREATE USER 'myappuser'@'localhost' IDENTIFIED BY 'StrongAppPass!';
GRANT ALL PRIVILEGES ON myappdb.* TO 'myappuser'@'localhost';
FLUSH PRIVILEGES;
This user now has full control over myappdb
but no access to other databases.
Assigning Privileges to the User
MariaDB gives you fine-grained control over what users can do. Here are examples of assigning specific privileges:
- Read-only:
GRANT SELECT ON myappdb.* TO 'readonlyuser'@'localhost';
- Modify-only:
GRANT INSERT, UPDATE, DELETE ON myappdb.* TO 'editoruser'@'localhost';
Always tailor privileges to the minimum required by the application or user. This keeps your database more secure and less prone to accidental damage.
Configuring MariaDB for Performance
Tuning MariaDB for better performance can significantly improve your application speed and resource usage, especially in a high-traffic or enterprise environment.
Understanding Configuration Files
MariaDB uses several configuration files, but the primary one is located at:
/etc/my.cnf.d/mariadb-server.cnf
In this file, you can tweak memory limits, connection settings, cache sizes, and more. It’s divided into sections:
[mysqld]
– Main server options[client]
– Settings for client programs[mysqld_safe]
– Startup options
Before making any changes, always back up the file:
sudo cp /etc/my.cnf.d/mariadb-server.cnf /etc/my.cnf.d/mariadb-server.cnf.bak
Optimizing Key Settings (Buffer Pool, Query Cache, etc.)
Let’s look at some critical settings you might want to adjust.
InnoDB Buffer Pool Size
This affects how much memory is used for storing data and indexes. For systems with 4GB+ RAM:
innodb_buffer_pool_size = 1G
Max Connections
Handles how many clients can connect at once:
max_connections = 200
Query Cache (for read-heavy workloads)
If your queries are mostly reads:
query_cache_type = 1
query_cache_size = 64M
After making changes, restart MariaDB:
sudo systemctl restart mariadb
Tuning settings depend heavily on your workload. Monitor and adjust gradually.
Monitoring Performance with Logs and Tools
To track performance and spot bottlenecks:
- MariaDB Slow Query Log – Logs queries taking longer than X seconds.
slow_query_log = 1
slow_query_log_file = /var/log/mariadb/slow.log
long_query_time = 2
- Performance Schema – Provides in-depth performance monitoring.
Enable it in the config:
performance_schema = ON
You can also use tools like:
- MySQLTuner: Gives you optimization suggestions.
- htop and iotop: For monitoring CPU, memory, and disk I/O in real-time.
MariaDB Backup and Restore on AlmaLinux
Backing up your data is non-negotiable. A single crash or mistake can wipe out months or years of work. Let’s walk through the most practical backup and restore methods.
Backing Up Databases Using mysqldump
mysqldump
is the standard command-line utility for backing up MariaDB databases.
To back up a single database:
mysqldump -u root -p myappdb > myappdb_backup.sql
To back up all databases:
mysqldump -u root -p --all-databases > alldb_backup.sql
You can even compress it on the fly:
mysqldump -u root -p myappdb | gzip > myappdb_backup.sql.gz
Make sure backups are stored somewhere safe, ideally offsite or in the cloud.
Restoring Databases from Backup
Restoring is just as simple. First, create the database if it doesn’t exist:
CREATE DATABASE myappdb;
Then restore:
mysql -u root -p myappdb < myappdb_backup.sql
For compressed files:
gunzip < myappdb_backup.sql.gz | mysql -u root -p myappdb
Always double-check that the restore was successful using SHOW TABLES;
.
Automating Backups with Cron Jobs
To make daily backups automatic, create a cron job.
Open the cron editor:
crontab -e
Add the following to run daily at 2 AM:
0 2 * * * mysqldump -u root -pMyPassword myappdb > /backup/myappdb_$(date +\%F).sql
Make sure the /backup
directory exists and has proper permissions. Also, avoid using plain passwords in scripts—use .my.cnf
files or secure vaults when possible.
Wireless Switch Controller for Switch/Lite/OLED Controller, Switch Controller with a Mouse Touch Feeling on Back Buttons, Extra Switch Pro Controller with Wake-up,Programmable, Turbo Function
Now retrieving the price.
(as of July 7, 2025 23:16 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Troubleshooting Common Issues
Sometimes things go wrong. Let’s cover common MariaDB issues and how to fix them.
Common Installation Errors and Fixes
- Package Not Found Error:
Ensure the MariaDB repo was created correctly. Try:sudo dnf clean all && sudo dnf makecache
- Conflicting Packages:
If MySQL is installed, remove it:sudo dnf remove mysql*
- Dependency Errors:
Try installing with:sudo dnf install MariaDB-server --nobest
Connection Issues and Firewall Rules
If you can’t connect remotely:
- Check bind-address in config
- Confirm firewall is open on port 3306
- Ensure the remote user has privileges
Also, test connectivity with:
telnet your-server-ip 3306
MariaDB Log Files for Debugging
MariaDB writes logs to:
- General Log:
/var/log/mariadb/mariadb.log
- Error Log:
/var/log/mariadb/mariadb.err
- Slow Query Log:
/var/log/mariadb/slow.log
(if enabled)
To tail logs in real-time:
sudo tail -f /var/log/mariadb/mariadb.err
Updating and Upgrading MariaDB
Keeping MariaDB updated ensures you get the latest security patches, performance improvements, and new features. But updates should be done carefully—especially on production systems.
Checking for Available Updates
First, check which version you currently have:
mysql -V
Then, look for available updates:
sudo dnf check-update MariaDB-server
If you’ve added the MariaDB official repository, this command should show the latest version.
To ensure your repo is pointing to the latest version, check:
cat /etc/yum.repos.d/MariaDB.repo
Make sure the baseurl
matches the latest stable version you want.
Upgrading MariaDB with DNF
To upgrade, use the following:
sudo dnf upgrade MariaDB-server -y
This will also upgrade dependencies. Once the upgrade is complete, restart the service:
sudo systemctl restart mariadb
Check the new version again to confirm the upgrade was successful.
Handling Configuration Changes During Upgrade
Sometimes MariaDB will prompt you with .rpmnew
or .rpmsave
files during upgrades. These indicate configuration file changes.
Use diff
to compare them:
diff /etc/my.cnf.d/mariadb-server.cnf /etc/my.cnf.d/mariadb-server.cnf.rpmnew
Decide whether to merge changes or keep your existing setup. Always back up your config files before upgrades.
Uninstalling MariaDB from AlmaLinux 10
Sometimes you need to start fresh, switch to another database system, or just remove MariaDB for troubleshooting. Here’s how to do a clean uninstall.
Removing MariaDB Packages
First, stop the service:
sudo systemctl stop mariadb
Then remove all MariaDB-related packages:
sudo dnf remove MariaDB-server MariaDB-client -y
Use dnf list installed | grep MariaDB
to confirm all packages have been removed.
Cleaning Up Configuration Files
Even after uninstalling, some config and data files may remain. Remove them manually:
sudo rm -rf /etc/my.cnf*
sudo rm -rf /var/lib/mysql
This will completely wipe out your data and configuration, so proceed with caution.
Verifying Complete Removal
Check that MariaDB is no longer running:
sudo systemctl status mariadb
It should return something like Unit mariadb.service could not be found
.
Double-check that no remnants remain:
which mysql
If it returns nothing, MariaDB is completely gone.
Advanced MariaDB Features
MariaDB isn’t just for simple databases. It has enterprise-grade features you can explore to scale and extend your setup.
Enabling Replication (Master-Slave)
Replication allows you to clone data from one MariaDB server to another.
On the Master:
Edit my.cnf
:
server-id=1
log-bin=mysql-bin
Create a replication user:
GRANT REPLICATION SLAVE ON *.* TO 'replicator'@'slave_ip' IDENTIFIED BY 'slavepass';
On the Slave:
Edit my.cnf
:
server-id=2
Set the master:
CHANGE MASTER TO MASTER_HOST='master_ip', MASTER_USER='replicator', MASTER_PASSWORD='slavepass', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=0;
START SLAVE;
Using Stored Procedures and Triggers
Stored procedures are blocks of SQL that you can reuse:
DELIMITER //
CREATE PROCEDURE HelloWorld()
BEGIN
SELECT 'Hello from MariaDB!';
END //
DELIMITER ;
Triggers let you automate actions, e.g., logging inserts:
CREATE TRIGGER before_insert_user
BEFORE INSERT ON users
FOR EACH ROW
SET NEW.created_at = NOW();
Setting Up MariaDB with Galera Cluster (Optional)
For high availability and fault tolerance, Galera clustering is a powerful solution. It lets you create a multi-master setup where each node can read/write data.
Basic steps:
- Install
MariaDB-galera-server
- Configure nodes with
wsrep_cluster_address
- Start the cluster with
galera_new_cluster
It’s complex but worth exploring for enterprise setups.
Read Also: How to install Galera Cluster on Rocky Linux 9
Best Practices for MariaDB on AlmaLinux
Once you’ve set up MariaDB, keeping it running smoothly long-term requires a few best practices.
Regular Maintenance Tips
- Run
ANALYZE TABLE
andOPTIMIZE TABLE
regularly. - Check for fragmented tables.
- Clear the slow query log periodically.
- Run backups on a schedule.
Example optimization:
OPTIMIZE TABLE users;
Keeping MariaDB Secure
- Use strong passwords and encryption
- Restrict remote access
- Avoid using
root
for applications - Regularly audit user privileges
- Use
iptables
orfirewalld
to control access
Don’t forget to update MariaDB when patches are released.
Monitoring and Alerts Setup
Use tools like:
- Nagios or Zabbix for monitoring
- Fail2ban to protect against brute force
- Audit plugins for tracking sensitive queries
Set up email or webhook alerts for anomalies like:
- High query time
- Low disk space
- Unauthorized login attempts
Video Tutorial
Frequently Asked Questions
1. How do I know if MariaDB is running properly?
Use systemctl status mariadb
to check if the service is active. You can also try connecting using mysql -u root -p
.
2. Can I install both MariaDB and MySQL on the same system?
Technically yes, but it’s not recommended. They share many files and ports, which can cause conflicts. Stick with one.
3. How do I change the MariaDB data directory?
- Stop MariaDB.
- Move
/var/lib/mysql
to your new directory. - Update the path in
my.cnf
. - Set correct permissions.
- Start MariaDB again.
4. Is MariaDB compatible with MySQL clients and tools?
Yes, it supports MySQL clients, connectors, and most SQL syntax. You can even migrate from MySQL to MariaDB without code changes.
5. What is the best way to secure MariaDB on a production server?
Use mysql_secure_installation
, disable root remote login, set strong passwords, limit user privileges, and enable firewall rules.
Conclusion
MariaDB on AlmaLinux 10 is a match made in open-source heaven. Whether you’re deploying a small application or powering a critical enterprise system, this setup gives you everything: speed, security, and reliability. With this guide, you’ve learned how to install, configure, secure, and optimize MariaDB—and even how to take it to the next level with replication, backups, and performance tuning.
The power is in your hands now. Keep it updated, secured, and backed up, and MariaDB will be your trusted companion for years to come.
Struggling with AWS or Linux server issues? I specialize in configuration, troubleshooting, and security to keep your systems performing at their best. Check out my Fiverr profile for details.
Leave a Reply
You must be logged in to post a comment.