How to install MySQL 8 on CentOS 8

MySQL Server is the most popular tool used for relational databases. It hosts multiple databases on a single server, allowing multi-user users to access these databases separately. As of this writing, MySQL Server 8.0 is available for installation. This release introduces some new features that are incompatible with some applications. So, first read the documentation for the application before deploying to a CentOS 8 server.

In this article, we will explain how to install MySQL on CentOS 8 using the terminal. We have implemented some required commands on CentOS system, which are mentioned below:

Installing MySQL on CentOS 8

To install MySQL server on your system, you need to follow these steps:

Step 1. Log in as root user. So, you can install some required packages on CentOS 8.

Step 2. Open a terminal by pressing Ctrl + Alt + t. Or, you can also launch a terminal application from the application launcher like this:

Step 3. You will now install MySQL Server 8 on your system using Yum Package Manager. Enter the following command in the terminal:

$ sudo dnf install @mysql

Install mysql with dns

You will press y to download and install the MySQL dependencies. When using the @mysql module, all dependencies and MySQL will be automatically installed on the system.

Confirm installation

After a while, the terminal will display a completion message. This means MySQL has been successfully installed on your system.

MySQL installation completed successfully.

Step 4. After the MySQL server 8 installation is complete, it’s time to start and enable the MySQL service using the following command:

$ sudo systemctl enable --now mysqld

Enable mysql service

Step 5. Before starting, it is recommended to check the status of the MySQL service as follows:

$ sudo systemctl status mysqld

In the following screenshot, you can see that my system is running MySQL services.

Check MySQL status

Step 6. To set a secure root password for the MySQL server, you run the following script:

$ sudo mysql_secure_installation

Installing MySQL securely

After executing the above script, it will ask you to configure a component for password validation named “validate_password”. You will press “y” and press the “Enter” key. It will automatically configure the password verification component. In the next request, he will ask you about the length of the password, three options will be available on your terminal: 0: low, 1: medium, 2: strong. You will choose option “2” for a strong password. Now you will set the root password. Enter the new root password, and then you need to enter the root password again. After that, the terminal will display additional user requests confirming the following questions:

  1. Or do you want to delete the anonymous user?
  2. Do you want to restrict root user access to the local computer?
  3. Do you want to drop the test database?
  4. Want to reload table privileges?

You must answer “yes” or type “y” to all required questions and continue.

Step 7. You will now interact with the MySQL server using the command line. Enter the following command to start the MySQL environment:

$ mysql -u root -p

You need to enter the root password you defined above. Your MySQL 8 server is now securely installed on your system. You can now learn more MySQL commands by working on them.

Create database using MySQL server

To create a database named vitux, you run the following command:

mysql> create database vitux;

Moreover, you can grant privileges to users with the following command:

mysql> GRANT ALL ON vitux.* TO [email protected] IDENTIFIED BY 'kbuzdar123';

If you want to close the MySQL command line environment, just write the following command, which will switch to a regular shell.

mysql> exit


In this article, you learned how to install MySQL server 8 on a CentOS 8 system. Hope you enjoyed this article and will find it useful in the future. Please share your opinion with us in the comments in the comment box.

How to install MySQL 8 on CentOS 8

Related Posts