MySQL忘记登录密码
跳过权限表的方式启动MySQL服务,进行密码修改
1、如果启动过mysql服务,则通过net stop mysql命令 或 systemctl stop mysql 停止服务
2、不同版本语句跳过权限表启动mysql服务
mysql8之前版本:mysqld --skip-grant-tables 回车 mysql8版本:mysqld --console --skip-grant-tables --shared-memory
3、当前窗口不关闭,重新使用管理员身份打开一个新控制台
mysql -u root -p 链接到服务器,直接回车 use mysql 切换到mysql数据库
4、修改用户密码
mysql5.7 之前版本: update user set password=password('密码') where user='root'; mysql5.7 之后版本 : alter user root@localhost identified with caching_sha2_password by '123456';
5、刷新权限
flush privileges;