mysql 版本:8.0.18

首先关闭MySQL服务,输入命令:

mysql> net stop MySQL

第一步:

我们需要删除data,也就是前面自动生成的data文件夹。

第二步:

删除成功后重新进行初始化:输入mysqld --initialize --console

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor:YES)

框内最后就是随机密码

mysql -u root -p

第三步:改密码

进入mysql后,执行:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '输入自己的密码';

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor:YES)

现在退出,在输入命令 “ mysql -u root -p ” 在输入刚才更新的密码,就可以正常登录到MySQL服务器了

相关文章:

  • 2021-09-05
  • 2021-12-25
  • 2021-07-17
猜你喜欢
  • 2021-08-22
  • 2021-12-14
  • 2021-07-16
  • 2021-10-25
  • 2021-09-15
  • 2021-08-01
  • 2022-02-18
相关资源
相似解决方案