This is a step-by-step guide on how to install MySQL 8.0 on CentOS 8 / RHEL 8 server. If you’re new to RHEL 8, you can find all RHEL 8 new features in my previous article Red Hat Enterprise Linux 8 (RHEL 8) New Features & Review. MySQL is a multi-threaded, multi-user SQL database server. It consists of the MySQL server daemon, mysqld, and many client programs.
RHEL 8 is distributed with MySQL 8.0 which has the following new features:
- Enhanced JSON functionality.
- MySQL 8.0 has support for roles. Roles are collections of privileges.
- It incorporates a transactional data dictionary, which stores information about database objects.
- Has support for common table expressions – recursive and nonrecursive
- Support for window functions, which perform a calculation for each row from a query, using related rows.
- It comes with InnoDB which support NOWAIT and SKIP LOCKED options with locking read statements.
Default authentication plug-in
Note that the MySQL 8.0 server distributed with RHEL 8 is configured to use
mysql_native_password as the default authentication plug-in because client tools and libraries in RHEL 8 are incompatible with the
caching_sha2_password method, which is used by default in the upstream MySQL 8.0 version.
For MariaDB users, I had written an article on installation of MariaDB 10.3 on RHEL 8 / CentOS 8 below:
Follow the steps provided here to install MySQL 8.0 on RHEL 8 / CentOS 8.
Step 1: Update your system
Ensure your system is updated.
sudo yum update
If you have kernel updates consider rebooting your system.
Step 2: Install MySQL 8.0 on RHEL 8 / CentOS 8
mysql 8.0 package is available in the AppStream repository and can be installed by running the command:
sudo dnf install @mysql:8.0
Confirm installation when prompted
Transaction Summary ======================================================================================================================================================= Install 7 Packages Total download size: 35 M Installed size: 229 M Is this ok [y/N]: y
The following packages will be installed
Installed: mariadb-connector-c-config-3.1.11-2.el8_3.noarch mecab-0.996-1.module+el8.3.0+242+87d3366a.9.x86_64 mysql-8.0.26-1.module+el8.4.0+652+6de068a7.x86_64 mysql-common-8.0.26-1.module+el8.4.0+652+6de068a7.x86_64 mysql-errmsg-8.0.26-1.module+el8.4.0+652+6de068a7.x86_64 mysql-server-8.0.26-1.module+el8.4.0+652+6de068a7.x86_64 protobuf-lite-3.5.0-13.el8.x86_64 Complete!
Step 3: Configure MySQL 8.0 on RHEL 8
sudo systemctl enable --now mysqld
Confirm service status:
$ 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 Thu 2022-05-05 23:39:02 EAT; 13s ago Process: 23548 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS) Process: 23416 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (code=exited, status=0/SUCCESS) Process: 23391 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS) Main PID: 23500 (mysqld) Status: "Server is operational" Tasks: 38 (limit: 49359) Memory: 464.0M CGroup: /system.slice/mysqld.service └─23500 /usr/libexec/mysqld --basedir=/usr May 05 23:38:58 rocky-linux-8.localdomain systemd: Starting MySQL 8.0 database server... May 05 23:38:58 rocky-linux-8.localdomain mysql-prepare-db-dir: Initializing MySQL database May 05 23:39:02 rocky-linux-8.localdomain systemd: Started MySQL 8.0 database server.
Once the service is started, run the command
mysql_secure_installation to harden MySQL database server.
$ 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: Please set the password for root here. New password:
Re-enter new password: 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!
- Set Database root user password
- Remove anonymous users
- Disallow root user remote logins
- Remove test database and access to it
When done, test access using the root user
$ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 11 Server version: 8.0.26 Source distribution Copyright (c) 2000, 2021, 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() | +-----------+ | 8.0.26 | +-----------+ 1 row in set (0.00 sec) mysql> QUIT Bye
You have now installed MySQL 8.0 database server on RHEL 8 / CentOS 8 system.