解决 MySQL 8.0 客户端连接 caching_sha2_password 问题

解决方法可用以下命令:

命令行登录mysql;
mysql>use mysql;
mysql>ALTER USER root IDENTIFIED WITH mysql_native_password BY '你的密码';
mysql>FLUSH PRIVILEGES;

网上说用:

MySql 8.0 C#连接报错 MySql.Data.MySqlClient.MySqlException (0x80004005): Authentication to host 'xxx' for user 'root' using method 'caching_sha2_password' failed with message: Reading from t
解决方法
在连接字符串后面加上   SslMode=None 

以上方法未成功,可能还是mysql 8.0密码验证机制问题导致,所以需要修改一下my.ini文件如下:

如果安装目录下找不到my.ini文件 windows系统下处理如下,打开C盘 查看选项中,查看隐藏文件,如果不出意外在programeData下(C:\ProgramData\MySQL\MySQL Server 8.0)找到my.ini

加入这一项 default_authentication_plugin=mysql_native_password

然后在服务中重启MySQL80服务

[mysqld]
default_authentication_plugin=mysql_native_password

Linux 下可以修改在/etc/my.cnf文件

发布了14 篇原创文章 · 获赞 4 · 访问量 3092

猜你喜欢

转载自blog.csdn.net/Angel_asp/article/details/105298992