How to Install MySQL on AlmaLinux

install mysql on almalinux

In this tutorial, we’ll be going over every step of how to install MySQL on AlmaLinux.

Database servers are the core of many web applications on the Internet. Their resource efficiency and great performance allow many users to read and write to websites simultaneously without issue. MySQL is one of the most popular database management platforms in the world. Since MySQL is not included by default on AlmaLinux, we’ll have to see how to install it.

Prerequisites

You only need a Linux VPS running AlmaLinux 8 or 9; both will work for this tutorial. You will also need root or superuser access to be able to run the commands needed to install the software.

Install MySQL on AlmaLinux 8

Install using DNF

The fastest and easiest method of installing MySQL on AlmaLinux is to use the built-in package manager, DNF. Short for Dandified YUM, this package manager is the evolution of YUM, which was used in previous years.

To install MySQL using the package manager, we need to ensure that we have the AppStream software repository enabled on our system. Run this command to see all of your repositories:

dnf repolist

You should get output that looks something like this:

repo id repo name
appstream AlmaLinux 8 - AppStream
baseos AlmaLinux 8 - BaseOS
epel Extra Packages for Enterprise Linux 8 - x86_64
extras AlmaLinux 8 - Extras

If AppStream is present in the list, then great! You do not need to enable anything. If you do not see an entry for AppStream, you will need to enable it using this command:

dnf config-manager --enable appstream

Once enabled, you can proceed with the installation.

To install the MySQL server, please run this command:

dnf install mysql-server

You will see a bunch of packages that need to be downloaded; these are dependencies and some additional packages that typically go together with the MySQL server, such as the client that allows you to interact with the server.

Press the [Y] key on your keyboard, then press [Enter] to confirm that you want to install the packages. When the command is finished, you will have installed the MySQL server on AlmaLinux 8 successfully.

Install using Packages from MySQL

If, for some reason, you need the latest version of MySQL server – even newer than what is included in the AppStream repository – you can download the packages directly from MySQL’s official website. Keep in mind that you’ll need to choose what packages you need for your use case. For this method, we will only show you the minimum steps required to install the main server package using a package download. You should repeat the process with any other packages that you need.

First, we’ll need to install the libaio package, which is required for MySQL. Install it like so:

dnf install libaio

Once done, we can now use the package downloads available on the MySQL website.

Visit the downloads page on MySQL’s website that contains the download links. In the “Select Operating System” dropdown, select “Red Hat Enterprise Linux / Oracle Linux”. Set the “OS version” dropdown to “Red Hat Enterprise Linux 8 / Oracle Linux (x86, 64-bit)”. You can select ARM or 32-bit if your server is running on that architecture. You can download the RPM bundle if you want all of the available packages in one download. If not, you can just click Download on the necessary packages. When taken to the login prompt, you can right-click on “No thanks, just start my download” and copy the link.

This list of packages is all required to be installed in order to be able to install MySQL server:

https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-common-8.0.32-1.el8.x86_64.rpm
https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-icu-data-files-8.0.32-1.el8.x86_64.rpm
https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-client-plugins-8.0.32-1.el8.x86_64.rpm
https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-libs-8.0.32-1.el8.x86_64.rpm
https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-client-8.0.32-1.el8.x86_64.rpm

You can download these packages onto your server by using the wget command. If you don’t have this tool installed on your system, you can install it using this command:

dnf install wget

Now you can download the packages using wget. This is one example:

wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-common-8.0.32-1.el8.x86_64.rpm

Once downloaded, you can install this .rpm file using the RPM command:

rpm -i mysql-community-common-8.0.32-1.el8.x86_64.rpm

With that, you now have the first required package installed. Repeat the process with all of the packages in the order they are listed above.

Finally, we can download and install the server package:

wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-server-8.0.32-1.el8.x86_64.rpm
rpm -i mysql-community-server-8.0.32-1.el8.x86_64.rpm

Install MySQL on AlmaLinux 9

Install using DNF

To install using the package manager, you can follow the exact same steps as AlmaLinux 8 above to get MySQL installed and running on your server.

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS

Install using packages from the MySQL website

The procedure is largely identical to AlmaLinux 8, with one key difference. In the OS dropdown on the download page, make sure to select Red Hat Enterprise Linux 9 / Oracle Linux 9 (x86, 64-bit). The rest of the procedure should be the exact same.

You now have the latest version of MySQL server installed on AlmaLinux!

Using MySQL Server

To start the server, you can run this command:

systemctl start mysqld

To make sure that MySQL runs automatically on server boot, you can run a similar command:

systemctl enable mysqld

Finally, you can run a command that will help you secure your MySQL installation.

mysql_secure_installation

This tool will let you set your MySQL root password, configure best practices for security, and delete the sample user and database. We highly recommend setting a root password for your MySQL user, as no password is set by default.

If you found this article useful and were able to install MySQL on your AlmaLinux server, please consider sharing the knowledge on social media or the Internet. You can also leave a comment if you want to show appreciation or if you have any better methods of installing MySQL. Thank you!

Leave a Comment