Reset password for MySQL8.0
Edit configuration file.
vim /etc/my.cnf
add “skip-grant-tables” in [mysqld] field.
Save and exit
Restart mysql service
systemctl restart mysqld
Login mysql
mysql -uroot -p
Switch database to mysql
mysql>use mysql;
Clear original password
mysql>update user set authentication_string = ” where user = ‘root’;
mysql>quit
vim /etc/my.cnf
Remove “skip-grant-tables” in [mysqld] field
save and exit
systemctl restart mysqld
mysql -uroot -p
mysql>ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘newpassword’;
mysql>quit
Login mysql by new password.