Wednesday, October 9, 2024
Google search engine
HomeData Modelling & AIHow To Install MySQL 8.0 on CentOS 8 / RHEL 8

How To Install MySQL 8.0 on CentOS 8 / RHEL 8

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 -y

If you have kernel updates consider rebooting your system.

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: 69 M
Installed size: 311 M
Is this ok [y/N]: y

Step 3: Configure MySQL 8.0 on RHEL 8

Activate mysqld service

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 2023-08-17 20:03:03 UTC; 1s ago
  Process: 58551 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
  Process: 58427 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (code=exited, status=0/SUCCESS)
  Process: 58402 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
 Main PID: 58505 (mysqld)
   Status: "Server is operational"
    Tasks: 39 (limit: 22612)
   Memory: 457.9M
   CGroup: /system.slice/mysqld.service
           └─58505 /usr/libexec/mysqld --basedir=/usr

Aug 17 20:02:57 rocky8.mylab.io systemd[1]: Starting MySQL 8.0 database server...
Aug 17 20:02:58 rocky8.mylab.io mysql-prepare-db-dir[58427]: Initializing MySQL database
Aug 17 20:03:03 rocky8.mylab.io systemd[1]: 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: <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
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!

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.32 Source distribution

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

Stay connected for more educative tutorials.

RELATED ARTICLES

Most Popular

Recent Comments