背景
接手别人项目进行维护,使用Mysql 8.0
数据库正确还原,但是项目却无法启动,经过调试发现以下问题。
MySqlException Authentication method ‘caching_sha2_password’ not supported by any of the available plugins。

通常的报这个错误是因为它的身份验证方式是 mysql_native_password
,不是caching_sha2_password
导致。
Mysql 官方相关资料:https://dev.mysql.com/doc/refman/8.0/en/caching-sha2-pluggable-authentication.html
解决方法
首先找到MySql 8.0
的安装目录,看一下是否存在my.ini
配置文件,默认安装路径如下:
C:\Program Files\MySQL\MySQL Server 8.0

现在并没有发现my.ini
配置文件,经过了解Mysql 8.0
安装后会将配置相关内容保存在以下目录中:
C:\ProgramData\MySQL\MySQL Server 8.0

打开my.ini
配置文件并找到caching_sha2_password
所在的行。

将default_authentication_plugin=caching_sha2_password
替换为default_authentication_plugin=mysql_native_password

操作完成后保存,然后重启mysql 8.0
服务即可。