MySQL – Reset the root password
If you have forgotten your root password (it was in my case) then you can do the followings steps:
I use here a Linux, Fedora 41.
If you are using other distributions or Windows / macOS, please search for this operating systems.
And if your system shows an error message, contact your favourite AI or a platform like StackOverflow.
I did it today for the first day on my system because I did not know the root password.
- sudo systemctl stop mysqld
- sudo mysqld_safe –skip-grant-tables &
- mysql -u root
- USE mysql;
- UPDATE user SET authentication_string = ‚ ‚ WHERE User = ‚root‘ AND Host = ‚localhost‘;
- FLUSH PRIVILEGES;
- Exit
- sudo pkill mysqld
- sudo systemctl start mysqld
- mysql -u root
- ALTER USER ‚root’@’localhost‘ IDENTIFIED BY ‚Dein_Neues_SuperSicheres_Passwort‘;
- Exit
- mysql -u root -p
- sudo systemctl enable mysqld
- sudo systemctl status mysqld
That’s all.