mysql 程序连接报错 Authentication method ‘caching_sha2_password’ not supported by any of the available plugins
自己在使用mysql过程中出现的问题,在网上找了很多资料,最终终于解决了,记录一下留下宝贵的经验,也供大家参考
①查看plugin设置(这一步是为了查看Plugin设置,如果看到root的plugin是‘caching_sha2_password’,那是不可以的,我们需要修正配置为‘mysql_native_password’)
1.1 方法一:select host, user, plugin from user;
※Windows键-》找到‘MySql’ -》找到‘Mysql . Command Line Client’ 点击进入-》输入密码后执行上面sql
1.2 方法二:登录MySQL客户端查看:
※进入Mysql客户端点击‘Administration’-》‘User and Privileges’-》在右侧的User Accounts栏中选中root,如下图
②修改Plugin配置
2.1 Windows键-》找到‘MySql’ -》找到‘Mysql . Command Line Client’ 点击进入-》输入密码后执行下面sql
2.2 mysql> ALTER USER root@localhost IDENTIFIED WITH mysql_native_password BY ‘xxxxx’;
2.3 mysql> FLUSH PRIVILEGES;
以上如不能解决问题,看下面
③修正my.ini文件
3.1 文件路径:版本不同路径会有所区别,mysql8.0.18目录如下(programData为隐藏目录)
3.2 记事本打开my.ini文件,修正如下配置
修正前:# The default authentication plugin to be used when connecting to the server
default_authentication_plugin=caching_sha2_password
修正后:# The default authentication plugin to be used when connecting to the server
default_authentication_plugin=mysql_native_password
3.3 修正后文件另存,保存时编码格式设置为‘ANSI’
3.4 重启mysql服务