微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

MySQL8.0版本以上密码重置方法

MysqL8.0的密码重置,以及提示“You must reset your password using ALTER USER statement before executing this statement.” 的解决方法

一、密码重置

1.停止MysqL服务
C:\> net stop MysqL
2.设置MysqL跳过权限表认证启动
C:\> MysqLd --console --skip-grant-tables --shared-memory 
3.重新打开一个命令提示符窗口,直接执行MysqL
C:\> MysqL
4.使用MysqL表格
MysqL> use MysqL;
5.把密码设为空
C:\> update user set authentication_string = ' '  where user='root' ; 
6.quit/exit 退出关闭开的“跳过权限认证启动”服务,ctrl+c或者直接关闭窗口都可,再打开MysqL服务
MysqL> quit
Bye
C:\> net start MysqL
7.最好就再打开一个新的窗口(现在前面的窗口都可以关掉了),输入 MysqL -uroot -p 后按enter(回车),再按一次回车(应为前面已经把密码设为空了)
C:\> MysqL -uroot -p
Enter password:
Welcome to the MysqL monitor.  Commands end with ; or \g.
Your MysqL connection id is 13
Server version: 8.0.25 MysqL Community Server - GPL

copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered Trademark of Oracle Corporation and/or its
affiliates. Other names may be Trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MysqL>

二、修改密码

MysqL> alter user user() identified by "需要修改密码";
输入后提示
Query OK, 0 rows affected (0.01 sec)
修改成功了

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐