Want to learn how to install MySQL 8 on Rocky Linux 8? Follow the simple steps provided in this guide.
Read about what is new in MySQL 8 on its manual reference page.
Installing MySQL 8 on Rocky Linux 8
MySQL 8 is available on the Rocky Linux 8 AppStream repos for installation. The AppStream repos are enabled by default.
dnf whatprovides mysql-server
mysql-server-8.0.21-1.module+el8.3.0+242+87d3366a.x86_64 : The MySQL server and related files
Repo : appstream
Matched from:
Provide : mysql-server = 8.0.21-1.module+el8.3.0+242+87d3366a
Hence, you can install MySQL 8 by running the command below;
dnf install mysql-server
You can also use the command below instead;
dnf install @mysql
Dependencies resolved.
============================================================================================================================================================================
Package Architecture Version Repository Size
============================================================================================================================================================================
Installing:
mysql-server x86_64 8.0.21-1.module+el8.3.0+242+87d3366a appstream 22 M
Installing dependencies:
checkpolicy x86_64 2.9-1.el8 baseos 345 k
mariadb-connector-c-config noarch 3.1.11-2.el8_3 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
perl-Carp noarch 1.42-396.el8 baseos 29 k
perl-Data-Dumper x86_64 2.167-399.el8 baseos 57 k
perl-Digest noarch 1.17-395.el8 appstream 26 k
perl-Digest-MD5 x86_64 2.55-396.el8 appstream 36 k
perl-Encode x86_64 4:2.97-3.el8 baseos 1.5 M
perl-Errno x86_64 1.28-419.el8 baseos 75 k
perl-Exporter noarch 5.72-396.el8 baseos 33 k
perl-File-Path noarch 2.15-2.el8 baseos 37 k
perl-File-Temp noarch 0.230.600-1.el8 baseos 62 k
perl-Getopt-Long noarch 1:2.50-4.el8 baseos 62 k
perl-HTTP-Tiny noarch 0.074-1.el8 baseos 57 k
perl-IO x86_64 1.38-419.el8 baseos 141 k
perl-MIME-Base64 x86_64 3.15-396.el8 baseos 30 k
perl-Net-SSLeay x86_64 1.88-1.module+el8.4.0+512+d4f0fc54 appstream 378 k
perl-PathTools x86_64 3.74-1.el8 baseos 89 k
perl-Pod-Escapes noarch 1:1.07-395.el8 baseos 19 k
perl-Pod-Perldoc noarch 3.28-396.el8 baseos 85 k
perl-Pod-Simple noarch 1:3.35-395.el8 baseos 212 k
perl-Pod-Usage noarch 4:1.69-395.el8 baseos 33 k
perl-Scalar-List-Utils x86_64 3:1.49-2.el8 baseos 67 k
perl-Socket x86_64 4:2.027-3.el8 baseos 58 k
perl-Storable x86_64 1:3.11-3.el8 baseos 97 k
perl-Term-ANSIColor noarch 4.06-396.el8 baseos 45 k
perl-Term-Cap noarch 1.17-395.el8 baseos 22 k
perl-Text-ParseWords noarch 3.30-395.el8 baseos 17 k
perl-Text-Tabs+Wrap noarch 2013.0523-395.el8 baseos 23 k
perl-Time-Local noarch 1:1.280-1.el8 baseos 32 k
perl-URI noarch 1.73-3.el8 appstream 115 k
perl-Unicode-Normalize x86_64 1.25-396.el8 baseos 81 k
perl-constant noarch 1.33-396.el8 baseos 24 k
perl-interpreter x86_64 4:5.26.3-419.el8 baseos 6.3 M
perl-libnet noarch 3.11-3.el8 appstream 120 k
perl-libs x86_64 4:5.26.3-419.el8 baseos 1.6 M
perl-macros x86_64 4:5.26.3-419.el8 baseos 71 k
perl-parent noarch 1:0.237-1.el8 baseos 19 k
perl-podlators noarch 4.11-1.el8 baseos 117 k
perl-threads x86_64 1:2.21-2.el8 baseos 60 k
perl-threads-shared x86_64 1.58-2.el8 baseos 47 k
policycoreutils-python-utils noarch 2.9-14.el8 baseos 251 k
protobuf-lite x86_64 3.5.0-13.el8 appstream 148 k
python3-audit x86_64 3.0-0.17.20191104git1c2f876.el8.1 baseos 85 k
python3-libsemanage x86_64 2.9-6.el8 baseos 126 k
python3-policycoreutils noarch 2.9-14.el8 baseos 2.2 M
python3-setools x86_64 4.3.0-2.el8 baseos 625 k
Installing weak dependencies:
perl-IO-Socket-IP noarch 0.39-5.el8 appstream 46 k
perl-IO-Socket-SSL noarch 2.066-4.module+el8.4.0+512+d4f0fc54 appstream 297 k
perl-Mozilla-CA noarch 20160104-7.module+el8.4.0+529+e3b3e624 appstream 14 k
Enabling module streams:
mysql 8.0
perl 5.26
perl-IO-Socket-SSL 2.066
perl-libwww-perl 6.34
Transaction Summary
============================================================================================================================================================================
Install 54 Packages
Total download size: 51 M
Installed size: 228 M
Is this ok [y/N]: y
Running MySQL 8 on Rocky Linux 8
Once the installation completes, start and enable MySQL 8 server to run on system boot.
systemctl enable --now mysqld
To check the status of MySQL 8 server;
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-06-30 18:14:46 EAT; 1h 30min ago
Process: 8119 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
Process: 7934 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (code=exited, status=0/SUCCESS)
Process: 7910 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Main PID: 8072 (mysqld)
Status: "Server is operational"
Tasks: 38 (limit: 4938)
Memory: 416.7M
CGroup: /system.slice/mysqld.service
└─8072 /usr/libexec/mysqld --basedir=/usr
Jun 30 18:10:06 localhost.localdomain systemd[1]: Starting MySQL 8.0 database server...
Jun 30 18:10:07 localhost.localdomain mysql-prepare-db-dir[7934]: Initializing MySQL database
Jun 30 18:14:46 localhost.localdomain systemd[1]: Started MySQL 8.0 database server.
MySQL 8 Initial Security
By default, MySQL ships with security script that is used to remove test MySQL server databases, remove anonymous users in the database, disable remote root login, set the password strength.
To run the script, simply execute the command;
mysql_secure_installation
When run, you are prompted whether to enable or disable password policy. If enabled, set the password policy and create the password that matches your chosen policy.
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
Next, remove anonymous users, disallow remote root login, remove test database and reload privileges tables to effect the changes made.
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!
You can now login to your MySQL 8 server as a root user with the password set above.
mysql -u root -p
To show MySQL version, you can run the query;
show variables like "version%";
+-------------------------+---------------------+
| Variable_name | Value |
+-------------------------+---------------------+
| version | 8.0.21 |
| version_comment | Source distribution |
| version_compile_machine | x86_64 |
| version_compile_os | Linux |
| version_compile_zlib | 1.2.11 |
+-------------------------+---------------------+
5 rows in set (0.00 sec)
mysql>
You can as well run the command below on command line to show database version.
mysql -V
mysql Ver 8.0.21 for Linux on x86_64 (Source distribution)
You can now go ahead and administer your database as you so wish.
Other Tutorials
Install phpMyAdmin on Rocky Linux 8