Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading from stream failed - mysql_native_password error

I have been facing the following error intermittently.

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

It shots up any time and I am at my wits end. I also posted a bug on MySQL bugs and solutions are not proving to be effective in any way.I hope you guys can help me out.

Here is the link to MySQL Bug for details: Never seems to go away!

Some more detail: I have a client-server system but this bug occurs on the server system(where MySQL database is installed) when a local running app on the server system tries to run a query.

I had already opened a question here but since has been dead. Just a caveat I thought that skip-name-resolve solved the issue but it seems to just have lowered the frequency. Hope someone would help me out this time around.

EDIT: The MySQL guys say that in a client server setup server may close a connection if it is unused for a long time. However, this is not what I am facing as I create a new connection everytime I want to execute a query. I made this point clear in the last comment on the MySQL Bugs.

like image 653
Shyamal Parikh Avatar asked May 12 '15 17:05

Shyamal Parikh


4 Answers

Guys I tried this: "SslMode=None" in the connection string, but if you need SSL then read this: http://www.voidcn.com/article/p-phfoefri-bpr.html

here is a sample connection string that works:

connectionString="Server=192.168.10.5;Database=mydata;Uid=root;Pwd=****;SslMode=None" 

Hope this helps

like image 100
ZAFMA Avatar answered Nov 13 '22 11:11

ZAFMA


unfortunately, this error occurs if the application and mysql are on the same computer, if you move it to a different computer it is fine.

I tried many ways but for now there is no other solution. bug has been reported many times by others https://bugs.mysql.com/bug.php?id=76597

like image 29
yhackup Avatar answered Nov 13 '22 10:11

yhackup


I've been getting this error, quite frequently with Amazon's MySQL RDS instances. And most multi-AZ instances.

  • It would be interesting to compare notes to see if others mostly get this issue with RDS also?

Amazon is known to rely heavily on "fast" DNS changes to switch over stuff with things like ELBs. I wonder if the same thing is happening with RDS? Or some other internal AWS switching is messing up the idle connections in the pool.

This would explain why the Oracle devs can't reproduce it and don't see it as much of an issue.

Anyway I've had to just deal with it and add retry logic when opening a connection.

like image 3
Harry Avatar answered Nov 13 '22 09:11

Harry


This issue is caused by Ssl.

Solution 1: SSL is not required. Since it is caused by SSL, we can turn off SSL by appending "SslMode=None" to the connection string.

Solution 2: SSL is required, server identity is important and needs to be verified. The server needs a internet connection to do the cert verification. Please note the crypto API doesn't update CTL for every process. The CTL is maintained at operating system level. Once you connect the server to connect and make an SSL database connection to the server, the CTL will be updated automatically. Then you may disconnect the internet connection. Note again the CTL has its expiration date and after that the Windows needs to update it again. This will occur probably after several months.

Solution 3: SSL is required but the server identity is not important. Typically SSL is only used to encrypt the network transport in this case. We can turn off CTL update:

Press Win+R to open the "Run" dialog Type "gpedit.msc" (without quotes) and press Enter In the "Local Group Policy Editor", expand "Computer Configuration", expand "Administrative Templates", expand "System", expand "Internet Communication Management", and then click "Internet Communication settings". In the details panel, double-click "Turn off Automatic Root Certificates Update", clickEnabled, then click OK. This change will be effective immediatelly without restart.

http://www.voidcn.com/article/p-phfoefri-bpr.html

like image 3
Nyagaka Enock Avatar answered Nov 13 '22 09:11

Nyagaka Enock