Authentication to host '10.167.32.123' for user 'root' using method 'mysql_native_password' failed with message: Reading from the stream has failed

发布时间 2023-06-26 18:03:41作者: 之广

连接Mysql5.7以上的版本的数据库出现报错:

C#连接远程连接mysql时,抛异常:Authentication to host '10.167.32.123' for user 'root' using method 'mysql_native_password' failed with message: Reading from the stream has failed

最终在Mysql官网的bug提交区发现已经有人也遇到同样的问题并给出了解决方案,引起此错误的主要原因是在Mysql5.7及其以上版本中引入了SSL验证方式,如果不需要用到SSL验证,则在连接字符串时需要加入"SslMode=None"。如:server=10.167.32.123;port=3307;user=root; password=123456;database=intelligentpatrol;SslMode=None;就好了。