MySQL reset root passord
Stop the current running MySQL Service
1
2
sudo systemctl stop mysql
Create a run directory for mysql and give permission
1
2
sudo mkdir -p /var/run/mysqld
sudo chown mysql:mysql /var/run/mysqld
Start the MySQL service in Safe mode
1
2
sudo mysqld_safe --skip-grant-tables --skip-networking &
Login to mysql as root without password
1
2
mysql -u root
Update the MySQL password to null
1
2
3
UPDATE mysql.user SET authentication_string=null WHERE User='root';
FLUSH PRIVILEGES;
exit;
Login again and set the password
1
2
3
4
mysql -u root
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd';
Restart and try with new password
This post is licensed under CC BY 4.0 by the author.