忘记Mysql的root密码 重置Mysql密码

  1. 忘记mysql密码
  2. 停止mysql服务 /etc/init.d/mysqld stop
  3. 终止Mysql进程 killall -TERM mysqld
  4.  
  5. 安全模式启动Mysql
  6. [root@localhost ~]# /usr/bin/mysqld_safe --skip-grant-tables &
  7.  
  8. mysql  -p  回车直接进
  9.  
  10. mysql> use mysql;
  11. Reading table information for completion of table and column names
  12. You can turn off this feature to get a quicker startup with -A
  13.  
  14. Database changed
  15. mysql> update user set password=password('新密码') where user='root';
  16. Query OK, 3 rows affected (0.00 sec)
  17. Rows matched: 3  Changed: 3  Warnings: 0
  18.  
  19. mysql> flush privileges;
  20. Query OK, 0 rows affected (0.01 sec)
  21.  
  22. mysql> quit
  23. Bye
  24.  
  25. [root@localhost ~]# service mysqld restart  重启mysql
  26.  
  27. root的新密码进mysql
  28. [root@localhost ~]# mysql -p
  29. Enter password:
  30. Welcome to the MySQL monitorCommands end with ; or \g.
  31. Your MySQL connection id is 2
  32. Server version: 5.0.77 Source distribution
  33.  
  34. Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  35.  
  36. mysql>

2 Comments

  1. 我昨天也忘了密码了,进不去…..方法同上,成功重置^_^

  2. 我是笨猫,请问你的链接是否出售啊