美文网首页
MySQL忘记密码

MySQL忘记密码

作者: 王世军Steven | 来源:发表于2017-06-28 15:41 被阅读14次

MySQL修改密码的四种方式

1. 用SET PASSWORD命令

  • 登录MySQL
  • 输入命令
    • 格式 : mysql> set password for 用户名@localhost = password('新密码');
    • 例子 : mysql> set password for root@localhost = password('123');

2. 用mysqladmin

  • 输入命令
    • 格式 : mysqladmin -u用户名 -p旧密码 password 新密码
    • 例子 : mysqladmin -uroot -p123456 password 123

3. 用UPDATE直接编辑user表

  • 登录MySQL
  • mysql> use mysql;
  • mysql> update user set password=password('123') where user='root' and host='localhost';
  • mysql> flush privileges;

4. 忘记Root密码

  • 关闭MySQL服务 : net stop mysql
  • 输入 : mysqld --skip-grant-tables
    • 这种方式启动MySQL服务会不进行权限检查.但是cmd会卡在界面上.
  • 开启新的命令行
  • mysql> use mysql;
  • mysql> update user set password=password('123') where user='root' and host='localhost';
  • mysql> flush privileges;
  • mysql> exit
  • 注销系统

参考 : http://www.jb51.net/article/39454.htm

相关文章

网友评论

      本文标题:MySQL忘记密码

      本文链接:https://www.haomeiwen.com/subject/ymmucxtx.html