问题原因:
Mysql8.0之前版本加密方式是mysql_native_password
而之后的版本加密方式改为 caching_sha2_password
解决办法:
# 先连接到mysql数据库
# 执行以下命令
# 设置密码永不过期
alter user 'root'@'localhost' identified by '123456' password expire never;
# 设置加密规则为mysql_native_password
alter user 'root'@'localhost' identified with mysql_native_password by '123456';
# 如果上述方式无效使用以下命令尝试
alter user 'root'@'%' identified by '123456' password expire never;
alter user 'root'@'%' identified with mysql_native_password by'123456';