Guides 11792 Published by

A quick, no‑fluff guide to getting the latest MariaDB up and running on Rocky Linux 8 – from adding the official repo and installing the server, to enabling it at boot, hardening security with mysql_secure_installation, and confirming everything works. Perfect for anyone who wants a reliable MySQL drop‑in without the hassle.



How to Install MariaDB on Rocky Linux 8 – Fast, Secure, No Surprises

You’ve got a fresh Rocky 8 box and need a reliable SQL engine without the MySQL licensing drama. This guide walks you through pulling the newest MariaDB packages, getting the service up at boot, and locking it down so nobody can walk in and delete your tables.

Grab the right repo – don’t settle for the distro’s ancient copy

Rocky 8 ships with MariaDB 10.3 in its base repository. That version works, but I’ve hit a snag when an application required features added in 10.5. The fix is to add the official MariaDB repo and let dnf fetch the current release.

sudo tee /etc/yum.repos.d/MariaDB.repo <<EOF
[mariadb]
name = MariaDB
baseurl = https://yum.mariadb.org/10.11/rhel8-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF

Why this matters: The repo points to the upstream build, so you get security patches and new features faster than Rocky’s lagging package.

Install the server package

Now that the correct source is in place, pull the server and client tools:

sudo dnf install mariadb-server mariadb-client

dnf will resolve dependencies and drop the binaries into /usr/bin. If it asks for confirmation, hit y Enter – you’re telling the system “I trust this repo”.

Start MariaDB and make sure it survives reboots

sudo systemctl start mariadb sudo systemctl enable mariadb

systemctl start launches the daemon right now; enable writes a symlink so the service is automatically started on every boot. After you run them, double‑check:

sudo systemctl status mariadb

You should see “active (running)”. If the line says “failed”, look at the journal with journalctl -u mariadb – most failures are missing directories or SELinux blocks.

Harden the installation

The default install lets anyone on the box connect as the MySQL root user without a password. That’s fine for a throwaway test server, but not for anything you care about.

sudo mysql_secure_installation

You’ll be prompted to set a root password, remove anonymous accounts, disallow remote root logins, and drop the test database. Say y to each prompt unless you have a very specific reason to keep them. I’ve seen folks skip this step and later get hit by ransomware that silently creates a new admin account – avoid that drama.

Verify everything works

A quick sanity check confirms both the client and server talk to each other:

mysqladmin -u root -p version

Enter the password you just set. The output should list the MariaDB version (10.11.x if you followed the repo steps) and show a small uptime counter. If it prints “Can't connect to local MySQL server”, revisit the status command – the service may have failed to start.

Real‑world tip: watch out for leftover MySQL packages

On my first Rocky 8 migration, I forgot to purge an old mysql-community-server that was still sitting in /etc/my.cnf. MariaDB started fine but kept reading the stale config and refused remote connections. Running:

sudo dnf remove mysql-community-*

and then re‑starting MariaDB solved it instantly.

That’s it – you now have a fresh, up‑to‑date MariaDB instance humming on Rocky 8, secured against the usual rookie mistakes, and ready for your applications.