Unable to load authentication plugin 'caching_sha2_password'

连接数据库报错:
Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Unable to load authentication plugin ‘caching_sha2_password’.)

Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Unable to load authentication plugin 'caching_sha2_password'.)

测试了一下…连接公司的数据库没问题,换成本地数据库报如上错误,所以问题出在本地的MySQL。
查看MySQL的配置文件my.ini
Unable to load authentication plugin 'caching_sha2_password'
发现有点熟悉…和报错信息一样。
百度了一下,原因是:在mysql8.0之前的版本使用的密码加密规则是mysql_native_password,但是在mysql8则是caching_sha2_password。

又看了下本地的MySQL版本:8.0没错。
Unable to load authentication plugin 'caching_sha2_password'
解决方法:
1》win+r,cmd进入命令行
2》输入mysql -uroot -pxxx (xxx为密码)进入mysql
3》输入如下代码:(password换成相应密码)

ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
FLUSH PRIVILEGES;
alter user 'root'@'localhost' identified by 'password';

Unable to load authentication plugin 'caching_sha2_password'
重试了一下…问题解决~

解决方法参考:
mysql8 :客户端连接caching-sha2-password问题
https://blog.csdn.net/u010026255/article/details/80062153

上一篇:解决错误 java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @Co


下一篇:Android Studio 非正常关闭再打开时报错