网上查到的原因是:
mysql8 之前的版本中加密规则是mysql_native_password;
mysql8之后,加密规则是caching_sha2_password;
找到的解决方法是:
把mysql用户登录密码加密规则还原成mysql_native_password;
【自定义密码】如“password”
输入sql语句:
#修改加密规则
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
#更新一下用户的密码:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
#刷新权限
FLUSH PRIVILEGES;
连接成功
补充【如果报错如图】:
是因为密码没有替换! password
修改密码为123456语句:
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';