Guest User

Untitled

a guest
Feb 15th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. 方法1: 用SET PASSWORD命令
  2. ```
  3. mysql -u root
  4.  
  5. mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');
  6. ```
  7. 方法2:用mysqladmin
  8. ```
  9. mysqladmin -u root password "newpass"
  10. ```
  11. 如果root已经设置过密码,采用如下方法
  12. ```
  13. mysqladmin -u root password oldpass "newpass"
  14. ```
  15. 方法3: 用UPDATE直接编辑user表
  16. ```
  17. mysql -u root
  18.  
  19. mysql> use mysql;
  20.  
  21. mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root';
  22.  
  23. mysql> FLUSH PRIVILEGES;
  24. ```
  25. 在丢失root密码的时候,可以这样
  26. ```
  27. mysqld_safe --skip-grant-tables&
  28.  
  29. mysql -u root mysql
  30.  
  31. mysql> UPDATE user SET password=PASSWORD("new password") WHERE user='root';
  32.  
  33. mysql> FLUSH PRIVILEGES;
  34. ```
Add Comment
Please, Sign In to add comment