In today’s article we shall install MySQL 5.7 on Rocky Linux 8 | AlmaLinux 8. MySQL is a universally adopted Relational SQL Database Management System. MySQL database powers Web, Desktop, Gaming, Banking applications among many other critical workloads in enterprise setups. MySQL development was initially under MySQL AB, a Swedish company, before being acquired by Oracle Corporation in 2010. If you’ll need support for your MySQL server installations, Oracle is the company to contact.
MySQL is a multi-user, multi-threaded SQL database server that uses a client/server implementation consisting of a server daemon (mysqld) and many different client programs and libraries. Our focus will be on the installation of MySQL server and client packages. We will install MySQL Community Server 5.7 on Rocky Linux 8 | AlmaLinux 8.
Some the the features added in MySQL 5.7 are:
- Security improvements – Many security improvements in 5.7 release
- SQL mode changes. – Strict SQL mode for transactional storage engines
- InnoDB enhancements – Multiple
InnoDB
enhancements added in MYSQL 5.7. - JSON support – Beginning with MySQL 5.7.8, MySQL supports a native JSON type
- System and status variables – System and status variable information is now available in Performance Schema tables
- Condition handling – MySQL 5.7 supports stacked diagnostics areas.
- Logging – Addition of native syslog support extended to include Windows support
- Changing the replication source without STOP SLAVE
- Among many other features
Install MySQL 5.7 on Rocky Linux 8 | AlmaLinux 8
Follow the steps highlighted in the next sections to have a working installation of MySQL 5.7 on Rocky Linux 8 | AlmaLinux 8.
Step 1 – Update System
As usual, ensure your Rocky or AlmaLinux system is updated:
sudo dnf -y update
Upon a successful upgrade, perform system reboot to use new features from updates:
sudo systemctl reboot
Step 2 – Add EL7 based MySQL Repository
The default Rocky Linux 8 | AlmaLinux 8 only contains MySQL 8.0 packages. The same is applicable to MySQL Community Server repositories provided by Oracle. The hack around this involve the use of Enterprise Linux 7 based systems repositories.
Add the repo by running the commands below:
sudo tee /etc/yum.repos.d/mysql-community.repo<<EOF
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/\$basearch/
enabled=1
gpgcheck=0
[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/7/\$basearch/
enabled=1
gpgcheck=0
[mysql-tools-community]
name=MySQL Tools Community
baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/7/\$basearch/
enabled=1
gpgcheck=0
EOF
The commands executed also adds connectors and tools repositories for MySQL 5.7. Once configured, disable default mysql AppStream modules:
sudo dnf remove @mysql
sudo dnf -y module reset mysql
sudo dnf -y module disable mysql
Step 3 – Install MySQL 5.7 on Rocky Linux 8|AlmaLinux 8
Disable MySQL 8.0 community repo:
sudo dnf config-manager --disable mysql80-community
Then enable one for MySQL 5.7:
sudo dnf config-manager --enable mysql57-community
And lastly install MySQL 5.7 on Rocky Linux 8 | AlmaLinux 8 system:
sudo dnf install mysql-community-server
Review all dependencies and proceed if satisfied:
MySQL 5.7 Community Server 6.9 kB/s | 2.6 kB 00:00
MySQL Connectors Community 6.9 kB/s | 2.6 kB 00:00
MySQL Tools Community 7.0 kB/s | 2.6 kB 00:00
Dependencies resolved.
=====================================================================================================================================================
Package Architecture Version Repository Size
=====================================================================================================================================================
Installing:
mysql-community-server x86_64 5.7.44-1.el7 mysql57-community 184 M
Installing dependencies:
mysql-community-client x86_64 5.7.44-1.el7 mysql57-community 31 M
mysql-community-common x86_64 5.7.44-1.el7 mysql57-community 313 k
mysql-community-libs x86_64 5.7.44-1.el7 mysql57-community 3.0 M
...
Use rpm command to check exact version of installed package:
$ rpm -qi mysql-community-server
Name : mysql-community-server
Version : 5.7.44
Release : 1.el7
Architecture: x86_64
Install Date: Fri Jan 31 16:21:23 2025
Group : Applications/Databases
Size : 834403500
License : Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved. Under GPLv2 license as shown in the Description field.
Signature : RSA/SHA256, Thu Oct 12 15:15:38 2023, Key ID 467b942d3a79bd29
Source RPM : mysql-community-5.7.44-1.el7.src.rpm
Build Date : Wed Oct 11 15:14:29 2023
Build Host : pb2-el7-35.regionaliad02.mysql2iad.oraclevcn.com
Relocations : (not relocatable)
Packager : MySQL Release Engineering <[email protected]>
Vendor : Oracle and/or its affiliates
URL : http://www.mysql.com/
Summary : A very fast and reliable SQL database server
Description :
The MySQL(TM) software delivers a very fast, multi-threaded, multi-user,
and robust SQL (Structured Query Language) database server. MySQL Server
is intended for mission-critical, heavy-load production systems as well
as for embedding into mass-deployed software. MySQL is a trademark of
Oracle and/or its affiliates
The MySQL software has Dual Licensing, which means you can use the MySQL
software free of charge under the GNU General Public License
(http://www.gnu.org/licenses/). You can also purchase commercial MySQL
licenses from Oracle and/or its affiliates if you do not wish to be bound by the terms of
the GPL. See the chapter "Licensing and Support" in the manual for
further info.
The MySQL web site (http://www.mysql.com/) provides the latest news and
information about the MySQL software. Also please see the documentation
and the manual for more information.
This package includes the MySQL server binary as well as related utilities
to run and administer a MySQL server.
Step 4 – Configure MySQL 5.7 on Rocky Linux 8|AlmaLinux 8
Start and enable mysqld service:
sudo systemctl enable --now mysqld
Service should be in running state:
$ systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2025-01-31 16:22:34 EAT; 30s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 70169 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 70115 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 70171 (mysqld)
Tasks: 27 (limit: 36115)
Memory: 301.8M
CGroup: /system.slice/mysqld.service
└─70171 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
Jan 31 16:22:28 RockyLinux_8 systemd[1]: Starting MySQL Server...
Jan 31 16:22:34 RockyLinux_8 systemd[1]: Started MySQL Server.
Get temporary password generated for root database user account:
$ sudo grep 'A temporary password' /var/log/mysqld.log |tail -1
2025-01-31T13:22:31.072465Z 1 [Note] A temporary password is generated for root@localhost: teai#gg;3krE
Use the password to access MySQL shell and secure it:
$ sudo mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root: <INPUT-PRINTED-PASSWORD>
The existing password for the user account root has expired. Please set a new password.
New password: <INPUT-NEW-PASSWORD>
Re-enter new password: <RE-ENTER-NEW-PASSWORD>
Proceed to set other security options:
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y
Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
Test access with set password:
$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.44 MySQL Community Server (GPL)
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> SELECT VERSION();
+-----------+
| VERSION() |
+-----------+
| 5.7.44 |
+-----------+
1 row in set (0.00 sec)
mysql> EXIT
Bye
Conclusion
In this article we’ve been able to install and secure MySQL 5.7 on Rocky Linux 8 | AlmaLinux 8. It is not an officially supported installation on EL8 system but it works for test purposes. For Production workloads, the recommended version of MySQL to run on Rocky Linux 8 | AlmaLinux 8 should be 8.0. If the application is still designed for 5.7, plan for upgrade to 8.0.
More guides on database admnistration: