How to Install MySQL 8.0 on RHEL & CentOS Stream 9

MySQL is a free software that helps you store and manage data in tables. Many people use RHEL and CentOS Stream 9, which are types of Linux systems, to run their computers and servers.

This article will show you how to install MySQL 8.0 on RHEL and CentOS Stream 9.

What you need

  • A computer or server with RHEL or CentOS Stream 9
  • A user account that can run commands as root

Step 1: Adding the MySQL Repository

To install MySQL 8.0 on RHEL and CentOS Stream 9, you need to add the MySQL repository to your system. This will let you download the newest version of MySQL and get updates automatically.

To install MySQL 8.0, you need the MySQL repository on your system. To do this, go to the terminal and get the package that sets up the repository:

$ wget

Once the download is completed, use the command below install it:

$ sudo dnf install mysql80-community-release-el9-1.noarch.rpm

Read: Booting CentOS 7 in GUI Mode

Step 2: MySQL 8.0 installation

You have added the MySQL repository to your system. Now you can install MySQL 8.0 with this command:

$ sudo dnf install mysql-community-server

To start the MySQL service, use this command after you finish installing it:

$ sudo systemctl start mysqld

Read: How to Install Elasticsearch on CentOS/RHEL 9

Step 3: Making MySQL safer to use

MySQL is not safe at first. It gives a short password to the root account when it is installed. You can find the password in the log file with this command:

$ grep ‘A temporary password is generated’ /var/log/mysqld.log | tail -1

2024-02-07T09:51:14.276452Z 6 [Note] [MY-710454] [Server] A temporary password is generated for root@localhost: LydKrb7cTw>8

As shown above, the current temporary password is : LydKrb7cTw>8

To secure it , run the command below :

sudo mysql_secure_installation

You’ll need to create a root password for MySQL and respond to some security questions. Answer them based on your preferences.

Read: How to solve “Cannot find a valid baseurl for repo” in CentOS

Step 4: Installation verification

To verify that the installation was successful, you can log into the MySQL shell by executing the command below:

$ mysql -u root -p

This command will prompt you to enter the password for the root user. Once you enter the correct password, you will be logged into the MySQL shell and can start using MySQL.


If you like the content, we would appreciate your support by buying us a coffee. Thank you so much for your visit and support.


Nikolaus Oosterhof

Nikolaus holds a degree in software development and has a strong passion for all things tech-related, especially gadgets with screens. Though he is nostalgic for older phone models, he's a retired gamer and continues to enjoy programming in open-source environments. Additionally, Nikolaus enjoys writing about Linux, macOS and Windows and has experience designing web pages.

Leave a Reply