How To Install MySQL 8.0 on RHEL/CentOS 8

In this article, We will see how To Install MySQL 8.0 on RHEL(redhat) 8 step by step.In this article, we are going to install fresh installation of MySQL on the server.

Step by step To Install MySQL 8.0 on RHEL 8:

1. First download and add the following MySQL Yum repository to your respective Linux distribution system’s repository list to install the latest version of MySQL.

wget https://repo.mysql.com/mysql80-community-release-el8-1.noarch.rpm

How To Install MySQL 8.0 on RHEL/CentOS 8

2. After downloading the package, now install the downloaded package with the following command.

sudo yum localinstall mysql80-community-release-el8-1.noarch.rpm

3. Install latest version of MySQL (currently 8.0) using the following command.

sudo yum install mysql-community-server

It asks confirmation, then type y and press enter.

4. Verify that the MySQL Yum repository has been added successfully by using the following command.

yum repolist enabled | grep "mysql.*-community.*"

MySQL Post Installation steps:

1. Lets verify MySQL status by running any of the following commands

service mysqld status systemctl status mysqld.service

2. By default MySQL not started. Start MySQL server by using below command.

sudo service mysqld start or sudo systemctl start mysqld.service

3. Now verify again status of MySQL Server.

4. Now, verify the version MySQL installed by running command mysql –version

Set the password for MySQL root user

The command mysql_secure_installation allows you to secure your MySQL installation by performing important settings like setting the root password, removing anonymous users, removing root login, and so on.

1. MySQL version 8.0 or higher generates a temporary random password in /var/log/mysqld.log after installation.

2. Get the temporary password by running following command.

grep 'temporary password' /var/log/mysqld.log

Yellow highlighted one is password on my RHEL server. In your case it may be different. Keep password with you, we have to use that in the next step.

3. Run the securing command mysql_secure_installation on your terminal. Then provide password which is temporary password got from above step.

4. Provide the new password for root user and read other options carefully to complete security task.

Connect to the MySQL Server

Connect to MySQL from your terminal by using following command.

mysql -u root -p

Thats all. We have successfully installed and performed MySQL post installation steps.