Guest User

Untitled

a guest
Jun 24th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. first step :
  2.  
  3. 1. Stop mysql:
  4. systemctl stop mysqld
  5.  
  6. 2. Set the mySQL environment option
  7. if mysqld_safe --skip-grant-tables & has error do this
  8. systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
  9.  
  10. 3. Start mysql usig the options you just set
  11. systemctl start mysqld
  12.  
  13. 4. Login as root
  14. mysql -u root
  15.  
  16. 5. Update the root user password with these mysql commands
  17. mysql> UPDATE mysql.user SET authentication_string = PASSWORD('MyNewPassword')
  18. -> WHERE User = 'root' AND Host = 'localhost';
  19. mysql> FLUSH PRIVILEGES;
  20. mysql> quit
  21.  
  22. *** Edit ***
  23. As mentioned my shokulei in the comments, for 5.7.6 and later, you should use
  24. mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
  25. Or you'll get a warning
  26.  
  27. 6. Stop mysql
  28. systemctl stop mysqld
  29.  
  30. 7. Unset the mySQL envitroment option so it starts normally next time
  31. systemctl unset-environment MYSQLD_OPTS
  32.  
  33. 8. Start mysql normally:
  34. systemctl start mysqld
  35.  
  36. Try to login using your new password:
  37. 7. mysql -u root -p
Add Comment
Please, Sign In to add comment