Stop MySQL:
systemctl stop mysqld
Set the mySQL environment option
systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
Start MySQL using the options you just set
systemctl start mysqld
Login as root without a password
mysql -u root
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
Stop MySQL
systemctl stop mysqld
Unset the MySQL environment option so it starts normally next time
systemctl unset-environment MYSQLD_OPTS
Start MySQL normally:
systemctl start mysqld
Try to login using your new password:
mysql -u root -p