This tutorial will help you to install MySQL 8 on CentOS 8 and RHEL 8 systems.


You must have shell access with sudo privileged account on CentOS 8 system.

Step 1 – Install MySQL

The MySQL 8 packages are available under the AppStrem repository under CentOS 8. Install the required packages using the following command. This will also install multiple dependent packages. After completing the installation, enable the MySQL service to auto-start on the system start. Also start service manually for the first time. Then check the service current status using the following command:

Step 2 – Secure MySQL Installation

The MySQL installation has been completed. Now you can connect the MySQL server without any password but we recommend to secure the MySQL installation. The MySQL packages provide mysql_secure_installation command to apply the security. Just run the below command on terminal: and follow the on-screen instructions. Below are the details which require user input.

Press y|Y for Yes, any other key for No: y Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2 New password: [ENTER STRONG PASSWORD HERE] Re-enter new password: RE ENTER PASSWORD HERE Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y Remove anonymous users? (Press y|Y for Yes, any other key for No) : y Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

Step 3 – Connect MySQL

You have finished the installation and secured the MySQL server. Now connect to MySQL server via console or install phpMyAdmin to use a graphical web interface.

Step 4 – Create Database and User

It’s not recommended to use ‘root’ users to connect databases from applications. So it is a good idea to create a separate user for your application database connection. Below are the commands to create a new MySQL database, then create a new MySQL user and assign privileges on the database. You can change the database and user name as per your requirements. Also, use a strong password for the user. Now, connect to MySQL server using the newly created user and list available databases.


You have successfully installed and configured MySQL 8.0 on CentOS 8 system. Your server is ready for production use. You may also require to configure automated database backup script for the production system.