Guest User

Untitled

a guest
Mar 16th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. If you don't remember the password you set for root and need to reset it, follow these steps:
  2.  
  3. Stop the mysqld server, this varies per install
  4. Run the server in safe mode with privilege bypass
  5. sudo mysqld_safe --skip-grant-tables;
  6.  
  7. In a new window connect to the database, set a new password and flush the permissions & quit:
  8. mysql -u root
  9.  
  10. For MySQL older than MySQL 5.7 use:
  11.  
  12. UPDATE mysql.user SET Password=PASSWORD('your-password') WHERE User='root';
  13.  
  14. For MySQL 5.7+ use:
  15.  
  16. USE mysql;
  17.  
  18. UPDATE mysql.user SET authentication_string=PASSWORD("your-password") WHERE User='root';
  19.  
  20. Refresh and quit:
  21.  
  22. FLUSH PRIVILEGES;
  23.  
  24. \q
  25.  
  26. mysql> UPDATE mysql.user SET Password=PASSWORD('your_new_password')
  27. WHERE User='root';
  28. ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
  29.  
  30. mysql> SET PASSWORD = PASSWORD('your_new_password');
  31. Query OK, 0 rows affected, 1 warning (0.01 sec)
  32.  
  33. Stop the safe mode server and start your regular server back. The new password should work now. Worked like a charm for me :)
Add Comment
Please, Sign In to add comment