mysql8.0.16修改密码

修改密码种类
  • 情况一:已知旧密码,修改旧密码
  • 情况二:忘记旧密码,重置密码(这里只说明这种情况)
解决办法:情况二
  • 停止mysql服务
    在这里插入图片描述

  • 在bin目录下输入:mysqld --console --skip-grant-tables --shared-memory(跳过权限验证,出现以下字样成功)
    -

  • 重新打开一个cmd,到bin路径下,输入:mysql -u root -p,出现输入密码字样,直接回车
    在这里插入图片描述

  • 将密码置为空,输入:update user set authentication_string=’’ where user=‘root’;
    在这里插入图片描述

  • 输入退出mysql命令:quit

  • 关闭设置了权限跳过的mysql服务,输入命令:net stop mysql

  • 重新开启mysql服务,输入:net start mysql(服务开启不了,点击服务开启失败的解决链接

  • 登录mysql,输入mysql -u root -p

  • 输入密码,上面将密码置空了,直接回车

  • 输入修改密码命令:ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘111111’;
    在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_42653522/article/details/103296638