The reason is MySQL v 5.7 or higher generates a temporary random password after installation and stored that in mysql error log file, located at /var/log/mysqld.log for an installation by the MySQL Yum repository on CentOS 7. It doesn’t use empty root password for mysql as previous version does, how to revert to old fashion?
Check what’s random password it generated when installing
# sudo grep 'temporary password' /var/log/mysqld.log
Login to mysql server as root
# mysql -u root -p
Change mysql root user’s password for the first time
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '{new password}';
Pls replace {new password} with below rules, e,g: ‘Goodpwd@1’
– at least 8 characters
– at least contains one Uppercase character
– at least contains one digit
– at least contains one special character
– at least 8 characters
– at least contains one Uppercase character
– at least contains one digit
– at least contains one special character
Run following sql command to remove validate_password plugin
mysql> uninstall plugin validate_password;
Set root password to the empty one
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '';