Install MySQL 5.7 on Rocky Linux 8|AlmaLinux 8

Posted on 287 views

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 ofMySQL 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 defaultRocky 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<

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                                                                                                                                            221 kB/s | 2.6 kB     00:00
MySQL Connectors Community                                                                                                                                            228 kB/s | 2.6 kB     00:00
MySQL Tools Community                                                                                                                                                 231 kB/s | 2.6 kB     00:00
Dependencies resolved.
======================================================================================================================================================================================================
 Package                                                Architecture                           Version                                        Repository                                         Size
======================================================================================================================================================================================================
Installing:
 mysql-community-server                                 x86_64                                 5.7.37-1.el7                                   mysql57-community                                 174 M
Installing dependencies:
 libaio                                                 x86_64                                 0.3.112-1.el8                                  baseos                                             31 k
 mysql-community-client                                 x86_64                                 5.7.37-1.el7                                   mysql57-community                                  25 M
 mysql-community-common                                 x86_64                                 5.7.37-1.el7                                   mysql57-community                                 311 k
 mysql-community-libs                                   x86_64                                 5.7.37-1.el7                                   mysql57-community                                 2.4 M

Transaction Summary
======================================================================================================================================================================================================
Install  5 Packages

Total download size: 202 M
Installed size: 878 M
Is this ok [y/N]: y

Use rpm command to check exact version of installed package:

$ rpm -qi mysql-community-server
Name        : mysql-community-server
Version     : 5.7.37
Release     : 1.el7
Architecture: x86_64
Install Date: Wed Jan 19 23:02:33 2022
Group       : Applications/Databases
Size        : 800688121
License     : Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. Under GPLv2 license as shown in the Description field.
Signature   : RSA/SHA256, Thu Dec 16 02:02:44 2021, Key ID 467b942d3a79bd29
Source RPM  : mysql-community-5.7.37-1.el7.src.rpm
Build Date  : Mon Nov 29 20:47:12 2021
Build Host  : pb2-el7-05.regionaliad02.mysql2iad.oraclevcn.com
Relocations : (not relocatable)
Packager    : MySQL Release Engineering 
Vendor      : Oracle and/or its affiliates
URL         : http://www.mysql.com/
Summary     : A very fast and reliable SQL database 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 Wed 2022-01-19 23:04:00 UTC; 22s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 5166 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 5112 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 5168 (mysqld)
    Tasks: 27 (limit: 49496)
   Memory: 330.8M
   CGroup: /system.slice/mysqld.service
           └─5168 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

Get temporary password generated for root database user account

$ sudo grep 'A temporary password' /var/log/mysqld.log |tail -1
2022-01-19T23:03:58.688374Z 1 [Note] A temporary password is generated for [email protected]: 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: 

The existing password for the user account root has expired. Please set a new password.

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 11
Server version: 5.7.37 MySQL Community Server (GPL)

Copyright (c) 2000, 2022, 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.37    |
+-----------+
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.

coffee

Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.