Recover/Reset MySQL root Password
systemctl stop
echo "ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';" > tmp-setpw
sudo -u mysql mysqld --init-file=/path/to/tmp-setpw
Create a second shell session and test if the password was set successfully. Then stop the process with a SIGTERM kill. And then start the normal server again systemctl start mysql
.