MySQL – Reset the root password

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.

  1. sudo systemctl stop mysqld
  2. sudo mysqld_safe –skip-grant-tables &
  3. mysql -u root
  4. USE mysql;
  5. UPDATE user SET authentication_string = ‚ ‚ WHERE User = ‚root‘ AND Host = ‚localhost‘;
  6. FLUSH PRIVILEGES;
  7. Exit
  8. sudo pkill mysqld
  9. sudo systemctl start mysqld
  10. mysql -u root
  11. ALTER USER ‚root’@’localhost‘ IDENTIFIED BY ‚Dein_Neues_SuperSicheres_Passwort‘;
  12. Exit
  13. mysql -u root -p
  14. sudo systemctl enable mysqld
  15. sudo systemctl status mysqld

That’s all.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert