How To Install MySQL 8.0 on CentOS 8 / RHEL 8

(: September 24, 2019)

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.

MySQL 8.0 Enhancements

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.{text-align:left} img{margin:0 auto 0 0}

For MariaDB users, I had written an article on installation of MariaDB 10.3 on RHEL 8 / CentOS 8 below:

How to Install MariaDB Database Server on RHEL 8

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

Step 2: Install MySQL 8.0 on RHEL 8 / CentOS 8

The 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


Step 3: Configure MySQL 8.0 on RHEL 8

Activate mysqld service

sudo systemctl enable --now mysql

Confirm service status:

$ sudo 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 2018-12-05 15:32:50 EST; 16s ago
  Process: 4387 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
  Process: 4262 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (code=exited, status=0/SUCCESS)
  Process: 4238 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
 Main PID: 4345 (mysqld)
    Tasks: 37 (limit: 5056)
   Memory: 358.9M
   CGroup: /system.slice/mysqld.service
           └─4345 /usr/libexec/mysqld --basedir=/usr

Dec 05 15:32:42 rhel8.localdomain systemd[1]: Starting MySQL 8.0 database server...
Dec 05 15:32:42 rhel8.localdomain mysql-prepare-db-dir[4262]: Initializing MySQL database
Dec 05 15:32:50 rhel8.localdomain systemd[1]: Started MySQL 8.0 database server.

Once the service is started, run the command mysql_secure_installation to harden MySQL database server.

$ 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: <ENTER NEW PASSWORD>
Re-enter new password: <CONFIRM 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

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y  

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

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

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...

 - Removing privileges on test database...

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

All done!

Ensure you:

  • 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.12 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

| 8.0.12    |
1 row in set (0.00 sec)

mysql> QUIT

You have now installed MySQL 8.0 database server on RHEL 8. Stay connected for more educative tutorials.

How To Install PostgreSQL 11 on CentOS / RHEL 8

How To Install Percona MySQL Server 8 on CentOS / RHEL 8{text-align:left} img{margin:0 auto 0 0}

Related Posts