Welcome to our guide on the installation of MySQL 8 on Rocky Linux 8 / AlmaLinux 8. MySQL is the most widely used and trusted relational database management platform in use today. MySQL 8.0 was released a while back and it is build to with a number of improvements to enable innovative DBAs and developers to create and deploy the next generation of applications on the latest technologies.
Some MySQL 8.0 key highlights include:
- MySQL Document Store
- Transactional Data Dictionary
- SQL Roles
- Default to utf8mb4
- Common Table Expressions
- Window Functions
- And much more.
As there are a notable number of new features in MySQL 8 you may need to consult your application support if you’re using third party solutions. For in-house application development read the new features in detail to decide if changes are required at the application level.
Without much theory let’s proceed straight to the installation of MySQL 8 on Rocky Linux 8 | AlmaLinux 8. Both Rocky and AlmaLinux 8 are based on RHEL 8 code. This means the process of installation will be similar. After installing MySQL 8.0 on Rocky Linux 8 | AlmaLinux 8 we will secure it.
Step 1: Update System
We always recommend beginning installation of any software package with OS upgrade if feasible option.
sudo dnf -y update
If Kernel updates are there you can perform a reboot hence proceed to the next step.
Step 2: Enable MySQL AppStream Module
On Rocky Linux 8 / AlmaLinux 8 MySQL 8 packages are available in an AppStream module as confirmed with the following command:
$ sudo dnf module list mysql
Last metadata expiration check: 1:22:08 ago on Wed 05 May 2021 01:40:11 PM EAT.
Rocky Linux 8 - AppStream
Name Stream Profiles Summary
mysql 8.0 [d] client, server [d] MySQL Module
Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
If the Module is not active enable it with the command below:
$ sudo dnf module enable mysql:8.0
Last metadata expiration check: 0:00:09 ago on Wed 05 May 2021 03:13:57 PM EAT.
Dependencies resolved.
==================================================================================================================================================================
Package Architecture Version Repository Size
==================================================================================================================================================================
Enabling module streams:
mysql 8.0
Transaction Summary
==================================================================================================================================================================
Is this ok [y/N]: y
Complete!
Step 3: Install MySQL 8 on Rocky Linux / AlmaLinux 8
Once the module is enabled proceed to install MySQL 8 on Rocky Linux 8 / AlmaLinux 8:
sudo dnf install @mysql
Agree to start installation of MySQL 8.0 on Rocky Linux 8 / AlmaLinux 8:
Dependencies resolved.
==================================================================================================================================================================
Package Architecture Version Repository Size
==================================================================================================================================================================
Installing group/module packages:
mysql-server x86_64 8.0.21-1.module+el8.3.0+242+87d3366a appstream 22 M
Installing dependencies:
mariadb-connector-c-config noarch 3.1.11-2.el8 appstream 14 k
mecab x86_64 0.996-1.module+el8.3.0+242+87d3366a.9 appstream 392 k
mysql x86_64 8.0.21-1.module+el8.3.0+242+87d3366a appstream 12 M
mysql-common x86_64 8.0.21-1.module+el8.3.0+242+87d3366a appstream 147 k
mysql-errmsg x86_64 8.0.21-1.module+el8.3.0+242+87d3366a appstream 580 k
protobuf-lite x86_64 3.5.0-13.el8 appstream 148 k
Installing module profiles:
mysql/server
Transaction Summary
==================================================================================================================================================================
Install 7 Packages
Total download size: 35 M
Installed size: 182 M
Is this ok [y/N]: y
With @mysql module the server/client packages are installed and all its dependencies.
Wait for the installation process to complete then start mysqld service:
sudo systemctl enable --now mysqld
Confirm service is in running state:
$ systemctl status mysqld
● mysqld.service - MySQL 8.0 database server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2021-05-05 15:17:41 EAT; 14s ago
Process: 4129 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
Process: 4002 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (code=exited, status=0/SUCCESS)
Process: 3977 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Main PID: 4085 (mysqld)
Status: "Server is operational"
Tasks: 39 (limit: 23412)
Memory: 431.5M
CGroup: /system.slice/mysqld.service
└─4085 /usr/libexec/mysqld --basedir=/usr
May 05 15:17:34 rocky.hirebestengineers.com systemd[1]: Starting MySQL 8.0 database server...
May 05 15:17:34 rocky.hirebestengineers.com mysql-prepare-db-dir[4002]: Initializing MySQL database
May 05 15:17:41 rocky.hirebestengineers.com systemd[1]: Started MySQL 8.0 database server.
Step 4: Secure MySQL 8 on Rocky Linux / AlmaLinux 8
After installation we can secure database server using mysql_secure_installation script.
You’ll be prompted to configure VALIDATE PASSWORD PLUGIN which is used to improve security by requiring account passwords and enabling strength testing of potential passwords. Three levels of password validation are available to choose from, LOW, MEDIUM and STRONG. low, medium, and strong. STRONG is recommended for all production setups.
$ sudo mysql_secure_installation
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?
Press y|Y for Yes, any other key for No: y
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Please set the password for root here.
New password:
Re-enter new password:
Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
Use MySQL client utility to test access to root user shell.
$ mysql -u root -p
Authenticate with the password set while securing the database server:
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.21 Source distribution
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
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>
Run below statement which prints the version of your MySQL server:
mysql> SELECT VERSION();
+-----------+
| VERSION() |
+-----------+
| 8.0.21 |
+-----------+
1 row in set (0.00 sec)
mysql> \q
Bye
Conclusion
That is how you can easily install MySQL 8.0 on Rocky Linux 8 / AlmaLinux 8 Linux system. As the packages are readily available in the AppStream repositories we could quickly install via dnf install @mysql command without any repo addition.