MySQL - authentication (but only part of the time)

I get the following error from time to time.

Authentication for the localhost host for the root user using the mysql_native_password method failed with the message: Reading from the stream failed.

I know that the connection string is correct - at first it was tested after the application was launched, and if it does not work, the application displays a message and exits.

Secondly, the functions that report this also use it to connect correctly in most cases, which happens only once and for all.

I tried switching to 127.0.0.1, but it does not seem to have changed.

This is on 64-bit Windows Server 2012.

I added 127.0.0.1 localhost to the host file.

In 99% of cases when the application works correctly and connects to the database, it gives this error from time to time.

In addition, I checked the show full processlist command and I only have a few connections at any time.

I lost to explain this, and cannot figure out how to fix it.

Thanks Jim

+4
source share
1 answer

This is very old, but since I just found a solution to this problem, I will share it just in case someone is still looking for it (as far as I can tell, this is a problem with current releases of Mysql).

This issue is described in this error report .

I quote here the most important answer to this error report:

[21 2014 15:40]

, .

Client-Server, , , Socket Id/ProccesId / , . , , , , , .

, . , : 10 , , , 10 .

( ), , , : ping , ping , :

....
MySqlConnection _conn = new MySqlConnection("MyConnectionString");
private void CheckConnection()
{
   if(!_conn.Ping())
   {
     _conn.Open();
   }
}
....

, : ping-, , , , , , , . , .

, , , , :

....
private void button1_Click(object sender, EventArgs e)
{
  //assuming that the connection is already open
  CheckConnectionState();
  var cmd = new MySqlCommand("select 1", _conn);
  cmd.ExecuteNonQuery();
}
....

, : , .

.

0

All Articles