Guides 11792 Published by

The post explains how to install MariaDB on AlmaLinux 9 using only official packages so you get the latest performance fixes without legacy MySQL bloat. It walks through adding the proper repository, installing the server and client, starting and enabling the service, and then securing the installation with a quick mysql_secure_installation script that sets a root password, removes anonymous users, disallows remote root logins, and deletes the test database. After that you can verify everything is running correctly, troubleshoot common library errors that may appear after kernel upgrades by reinstalling the client, and keep MariaDB patched by updating just its server package. Optional tips include adding the binary path to your shell environment for easier use of the mysql command line tool.



Install MariaDB on AlmaLinux 9: A Quick, No‑Nonsense Guide

In this post you’ll learn exactly how to get MariaDB up and running on an AlmaLinux 9 machine—no extra repos, no fussing with MySQL compatibility layers. If you’ve ever tried installing a database on a fresh RHEL‑8 fork and hit a wall, this is the recipe that gets past it.

Why MariaDB on AlmaLinux?

MariaDB is the community‑driven fork of MySQL that keeps up with the latest performance tweaks while staying fully compatible with the vast majority of PHP/MySQL applications. On AlmaLinux 9 you can pull in the official MariaDB 10.x packages straight from their repository, which means you’ll get the newest bug fixes and security patches without the bloat of a generic “mysql” meta‑package.

Enable the MariaDB Repository
sudo dnf config-manager --add-repo https://downloads.mariadb.org/mariadb/repositories/10.6/rpm/el/9/mariadb-10.6.repo

Why this matters: AlmaLinux’s default repositories don’t ship with MariaDB 10.x, so you need to point dnf at the official repo that matches your OS version (here, EL 9). Skipping this step and trying a generic “dnf install mariadb” will pull in an older 5.5 release or nothing at all.

Install MariaDB Server
sudo dnf install -y MariaDB-server MariaDB-client

The -y flag skips the prompt; useful for scripts or when you’re already comfortable with what’s being installed. The two packages give you the daemon and the command‑line client you’ll use to interact with it.

Start & Enable the Service
sudo systemctl start mariadb
sudo systemctl enable mariadb

Starting the service launches the database engine; enabling it guarantees that MariaDB boots on every system startup. If you forget this step, systemctl status mariadb will report “inactive” even though the binary exists.

Secure the Installation
sudo mysql_secure_installation

A quick walkthrough:

1. Set root password – I’ve seen servers where the root account had no password after an upgrade, and that’s a recipe for disaster.
2. Remove anonymous users – These are great in demos but useless (and risky) on production boxes.
3. Disallow remote root login – If you’re not explicitly opening ports to the world, don’t bother.
4. Delete test database – Old versions shipped a test schema that anyone could write to.

When prompted, answer “Y” to all for a locked‑down default configuration.

Verify the Installation
sudo systemctl status mariadb
mysql -u root -p -e "SELECT VERSION();"

The first command confirms MariaDB is running. The second logs in and prints something like 10.6.12-MariaDB—the exact version depends on the repo you added.

(Optional) Add MariaDB to Your PATH

If you’re going to be using mysql a lot, consider adding /usr/bin/mariadb-client to your $PATH. Most systems already include it by default, but if you’ve had path conflicts with other MySQL binaries, this clears the air.

echo 'export PATH=$PATH:/usr/bin' >> ~/.bashrc
source ~/.bashrc
Common Pitfall: Missing Library After a Kernel Upgrade

I ran into an issue on one of my servers after a recent kernel update: mysql started throwing “libmariadb.so.3 not found.” The fix was simply reinstalling the client package:

sudo dnf reinstall MariaDB-client

Reinstall pulls in any missing shared libraries that might have been dropped during the upgrade.

Keep MariaDB Up to Date
sudo dnf update --refresh MariaDB-server

Running dnf update on just the server package ensures you stay on the latest patch level without pulling unrelated packages into your system. It’s a good idea to set up a cron job or use systemctl enable dnf-automatic if you want unattended updates.

Wrap‑up

That’s it: MariaDB is installed, secured, and primed for production workloads on AlmaLinux 9. You’ve sidestepped the older MySQL repo, avoided the “no such package” errors that plague many newbies, and got a clean install ready to go.