Install MySQL 8 on CentOS, RHEL 6/7

To Add MySQL yum repository to your server, go to

https://dev.mysql.com/downloads/repo/yum/

Download the rpm file available.

For RHEL/CentOS 7

For RHEL/CentOS 6

Installing MySQL Server

Stop/Start MySQL

To stop/start MySQL, use service name “mysqld”.

MySQL 8 root Password

When MySQL first starts, it create a random password and store in MySQL log file. To find the MySQL root password, run

This default password don’t allow you to do anything, so login to MySQL with this password and set a secure password for root.

MYSQL_ROOT_PASSOWRD – replace it with you secure new MySQL root password.

Installing Older Version of MySQL

When you add MySQL repository, it activate latest version by default. If you want older version, say 5.7, you need to activate it.

To see available repository, run

To disable MySQL 8 repository, run

To enable MySQL 5.7 repository, run

Now installing MySQL server will install MySQL 5.7 instead of latest version.

MySQL CentOS