Reset Mysql root password | Centos 7 - fourslick/notes GitHub Wiki

systemctl stop mysqld
systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
systemctl start mysqld
mysql -u root 
mysql> use mysql;
mysql> update user set authentication_string=PASSWORD("yournewpassword") where User='root';
mysql> update user set Host='%' where user='root';
mysql> flush privileges;
systemctl stop mysqld
systemctl unset-environment MYSQLD_OPTS
systemctl start mysqld