Guides 11792 Published by

This guide walks through installing MySQL 8.0 on AlmaLinux 9 by first adding Oracle’s official repository file and then using DNF to install the server package. It reminds you to disable any old MySQL repos, start the mysqld service immediately with systemctl, and retrieve the temporary root password that appears in the log after installation. The next step is running mysql_secure_installation to set a permanent root password and tighten security by removing anonymous users and test databases. Finally, it confirms the setup works by logging into MySQL as root, noting that a misconfigured repository can easily cause install failures.



How to Install MySQL 8.0 on AlmaLinux 9 in Minutes

Installing MySQL 8.0 on AlmaLinux 9 is surprisingly straightforward if you follow the right steps. The process boils down to adding Oracle’s official repository, pulling the RPMs, and running a quick security tweak. Below is a no‑fuss guide that skips the fluff and gets your database server up and running.

1. Grab the Official MySQL Yum Repository

Oracle ships a ready‑to‑use repo file for RHEL 9‑compatible systems like AlmaLinux 9. Download it with curl (or wget) so you’re pointing straight to the latest 8.0 build:

sudo curl -L https://dev.mysql.com/get/mysql80-community-release-el9-1.noarch.rpm \
     -o mysql80-community-release-el9-1.noarch.rpm

Why this matters: The repo file tells your package manager where to fetch MySQL packages and which dependencies to pull in. Skipping it would leave you hunting for the right RPMs manually.

2. Install the Repo Package
sudo dnf install ./mysql80-community-release-el9-1.noarch.rpm

A quick note: The ./ ensures DNF uses your local file instead of trying to resolve a remote one. After this, dnf repolist should show a new entry called mysql80-community.

3. Disable the Old MySQL Repo (Optional but Handy)

If you’ve had MySQL on another distro before, you might have remnants that conflict. Disable any leftover repo files:

sudo dnf config-manager --disable mysql57-community

That clears the path so dnf pulls only from the 8.0 sources.

4. Install MySQL Server
sudo dnf install mysql-server

During installation, DNF automatically resolves and installs MariaDB‑compatible dependencies that MySQL needs. If you hit a dependency error, it usually means your system missed a base repository; run sudo dnf update first.

5. Start and Enable the Service
sudo systemctl enable --now mysqld

Enabling guarantees the server boots with every reboot. The --now flag starts it immediately so you can test it straight away.

6. Grab the Temporary Root Password

MySQL generates a random root password on first boot and logs it in /var/log/mysqld.log. Pull it out:

sudo grep 'temporary password' /var/log/mysqld.log | awk '{print $NF}'

This is your only chance to set the real root password. Forgetting it means a fresh install.

7. Secure MySQL Instantly

Run the interactive script that will:

  • Change the temporary root password.
  • Drop the anonymous user.
  • Disable remote root login (unless you specifically want it).
  • Remove the test database.
sudo mysql_secure_installation

When prompted, paste the temp password from step 6. Then answer “Y” for all security prompts. Most users say “Y” to everything except leaving the anonymous user—if you’re on a personal machine, that’s fine.

8. Verify Everything Is Working
mysql -u root -p

Enter the new root password. If you land in the MySQL prompt (mysql>), congratulations! Your server is up and ready for databases.

Real‑world note: I once had a colleague try to install MySQL on an AlmaLinux 9 box that still had a leftover mysql57-community repo enabled. The installer got stuck with a “no matching package” error until the old repo was disabled. A quick check of active repos saved us hours of debugging.

That’s all there is to it. You now have a fully functional MySQL 8.0 server on AlmaLinux 9, ready for your projects or that hobby blog you’re building.