Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
235 views
in Technique[技术] by (71.8m points)

c# - Why MySQL throws Exception when I launch my program first time: Error reading from the stream

Authentication to host '127.0.0.1' for user 'root' using method 'mysql_native_password' failed with message: Reading from the stream has failed. I've searched a lot about this issue and only Internet disconnect solved the problem. Why is that?

I use MYSQL 8 and C# winforms.

Connection code looks like this:

MySqlConnection conn = new MySqlConnection("datasource=127.0.0.1;username=root;password=password;database=my_tests");

The every next try I execute the command is successful! It happens only first time.

I very appreciate your time people. And would be very thankful for constructive help for a newbie like me.

question from:https://stackoverflow.com/questions/65626584/why-mysql-throws-exception-when-i-launch-my-program-first-time-error-reading-fr

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

When I put SslMode=None to a string so it looks like

MySqlConnection conn = new MySqlConnection("datasource=127.0.0.1;username=root;password=password;database=my_tests;SslMode=None");

the problem is gone. But I'm not sure if I want not to use it. Any other solutions would be great.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...