异常:com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException:Client does not support authentication protocol requested by server;consider upgrading MySQL client
原因:mysql8以前的版本加密规则是mysql_native_password,而mysql8之后,加密规则是caching_sha2_password。如果你使用mysql8.0以上版本,在数据库连接时会出现加密规则不适配。
解决:
1、首先在数据库查询一下自己的MySQL版本
SELECT user,host,plugin from mysql.user;
如果是:
caching_sha2_password
2.把用户密码登录的加密规则改成mysql_native_password这种加密方式
1)alter user ‘root’@‘localhost’ identified with mysql_native_password by ‘password’;
//password是你自己的密码
2)flush privileges;#刷新权限,使自己的修改生效
3.SELECT user,host,plugin from mysql.user //查看加密方式
变成:
caching_native_password
4.重新运行项目即可