错误 2013 (HY000):在“读取授权包”时失去与 MySQL 服务器的连接,系统错误:0
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21091850/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading authorization packet', system error: 0
提问by Up_One
I am getting the following error
我收到以下错误
ERROR 2013 (HY000): Lost connection to MySQL server at
'reading authorization packet', system error: 0
when trying to connect to my MySQL server.
尝试连接到我的 MySQL 服务器时。
What I am doing:
我在做什么:
- I have Master - Slave replication in MySQL that is working and just added load balance capabilities using F5.
- I have configured the F5 according to their site.
- 我在 MySQL 中有 Master - Slave 复制,它正在工作,并且刚刚使用 F5 添加了负载平衡功能。
- 我已经根据他们的网站配置了 F5。
But when I am trying to connect to my MySQL server using the IP that the F5 was configured with I get
但是当我尝试使用 F5 配置的 IP 连接到我的 MySQL 服务器时,我得到
ERROR 2013 (HY000): Lost connection to MySQL server at
'reading authorization packet', system error: 0
Any ideas?
有任何想法吗?
Update on my progress : ZERO
- i am getting the same error
I get no entries in the /var/log/secure as if somebody would try to authenticate coming form the ip where i had created my load balance server.
No enties in the mysql error log.
The command - returns nothing
更新我的进度:零
- 我遇到了同样的错误,我在 /var/log/secure 中没有任何条目,好像有人会尝试对来自我创建负载平衡服务器的 IP 进行身份验证。
mysql 错误日志中没有条目。
命令 - 不返回任何内容
mysql> SHOW GLOBAL STATUS LIKE 'Aborted_connections';
Empty set (0.00 sec)
I've already altered my my.cnf
file and add the
我已经更改了我的my.cnf
文件并添加了
[mysqld]
skip-name-resolve
Alterd the connect_timeout
to 10.
So it seems i get no response for the server i have created on my F5
I finally convinced the F5 admin to pass me the log for the F5 server and i have exctraced all i need form it.
Here is the output :
将其connect_timeout
更改为 10。
因此,我在 F5 上创建的服务器似乎没有收到任何响应,
我终于说服 F5 管理员将 F5 服务器的日志传递给我,并且我已经提取了所有我需要的信息。
这是输出:
Jan 28 15:46:39 tmm debug tmm[6459]: Rule /Common/iRule-f5_mysql_proxy <CLIENT_ACCEPTED>: BIG-IP MySQL Proxy -- clientside initial connection
Jan 28 15:46:39 tmm debug tmm[6459]: Rule /Common/iRule-f5_mysql_proxy <CLIENT_ACCEPTED>: BIG-IP MySQL Proxy -- clientside responding with server WELCOME packet
Jan 28 15:46:39 tmm debug tmm[6459]: Rule /Common/iRule-f5_mysql_proxy <CLIENT_DATA>: BIG-IP MySQL Proxy -- clientside authenticated flag not set
Jan 28 15:46:39 tmm err tmm[6459]: Rule /Common/iRule-f5_mysql_proxy <CLIENT_DATA>: BIG-IP MySQL Proxy -- mysql client: attempting to do something before authentication
Jan 28 15:46:39 tmm debug tmm[6459]: Rule /Common/iRule-f5_mysql_proxy <LB_SELECTED>: BIG-IP MySQL Proxy -- serverside selected pool /Common/foss-mysql-slave_pool node SLAVE-IP
Jan 28 15:46:39 tmm debug tmm[6459]: Rule /Common/iRule-f5_mysql_proxy <CLIENT_CLOSED>: BIG-IP MySQL Proxy -- clientside connection closed from MASTER-IP(XXXXXXX)
Jan 28 15:46:39 tmm debug tmm[6459]: Rule /Common/iRule-f5_mysql_proxy <SERVER_CLOSED>: BIG-IP MySQL Proxy -- serverside connection closed from node SLAVE-IP(XXXXXXXX)
I've replaced the ip for security sake !
为了安全起见,我已经更换了ip!
just as an extra- and i think is here the problem - my mysql version is 5.1.69-logThx All
作为一个额外的- 我认为问题就在这里 - 我的 mysql 版本是5.1.69-logThx All
采纳答案by jmail
从文档:
More rarely, it can happen when the client is attempting the initial connection to the server. In this case, if your connect_timeout value is set to only a few seconds, you may be able to resolve the problem by increasing it to ten seconds, perhaps more if you have a very long distance or slow connection. You can determine whether you are experiencing this more uncommon cause by using SHOW STATUS LIKE 'aborted_connections'. It will increase by one for each initial connection attempt that the server aborts. You may see “reading authorization packet” as part of the error message; if so, that also suggests that this is the solution that you need.
更罕见的是,当客户端尝试与服务器进行初始连接时,可能会发生这种情况。在这种情况下,如果您的 connect_timeout 值仅设置为几秒,您可以通过将其增加到十秒来解决问题,如果您的距离很远或连接速度很慢,可能会更长。您可以使用 SHOW STATUS LIKE 'aborted_connections' 来确定您是否遇到了这种更罕见的原因。服务器中止的每次初始连接尝试都会增加 1。您可能会在错误消息中看到“正在读取授权包”;如果是这样,那也表明这是您需要的解决方案。
Try increasing connect_timeoutin your my.cnffile
尝试在my.cnf文件中增加connect_timeout
Another style:
另一种风格:
MySQL: Lost connection to MySQL server at 'reading initial communication packet'
MySQL:在“读取初始通信数据包”时失去与 MySQL 服务器的连接
At some point, it was impossible for remote clients to connect to the MySQL server.
The client (some application on a Windows platform) gave a vague description like
Connection unexpectedly terminated
.When remotely logging in with the MySQL client the following error appeared:
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0
在某些时候,远程客户端无法连接到 MySQL 服务器。
客户端(Windows 平台上的某些应用程序)给出了一个模糊的描述,如
Connection unexpectedly terminated
.使用MySQL客户端远程登录时出现如下错误:
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0
On FreeBSD this happens because there was no match found in /etc/hosts.allow.
Adding the following line before the line saying ALL:ALL
fixes this:
在 FreeBSD 上,发生这种情况是因为在修复此问题的/etc/hosts.allow.
行之前添加以下行中没有找到匹配项ALL:ALL
:
mysqld: ALL: allow
On non-FreeBSD Unix systems, it is worth to check the files /etc/hosts.allow
and /etc/hosts.deny.
If you are restricting connections, make sure this line is in /etc/hosts.allow
:
在非 FreeBSD Unix 系统上,检查文件是值得的/etc/hosts.allow
,/etc/hosts.deny.
如果您限制连接,请确保此行位于/etc/hosts.allow
:
mysqld: ALL
or check if the host is listed in /etc/hosts.deny.
或检查主机是否在 /etc/hosts.deny.
In Arch Linux, a similar line can be added to /etc/hosts.allow
:
在 Arch Linux 中,可以将类似的行添加到/etc/hosts.allow
:
mysqld: ALL
回答by Bill Karwin
This is usually caused by an aborted connect. You can verify this by checking the status:
这通常是由中止的连接引起的。您可以通过检查状态来验证这一点:
mysql> SHOW GLOBAL STATUS LIKE 'Aborted_connects';
If this counter keeps increasing as you get the lost connections, that's a sign you're having a problem during connect.
如果此计数器在您失去连接时不断增加,则表明您在连接过程中遇到了问题。
One remedy that seems to work in many cases is to increase the timeout. A suggested value is 10 seconds:
在许多情况下似乎有效的一种补救措施是增加超时。建议值为 10 秒:
mysql> SET GLOBAL connect_timeout = 10;
Another common cause of connect timeouts is the reverse-DNS lookup that is necessary when authenticating clients. It is recommended to run MySQL with the config variable in my.cnf:
连接超时的另一个常见原因是对客户端进行身份验证时必需的反向 DNS 查找。建议使用 my.cnf 中的 config 变量运行 MySQL:
[mysqld]
skip-name-resolve
This means that your GRANT statements need to be based on IP address rather than hostname.
这意味着您的 GRANT 语句需要基于 IP 地址而不是主机名。
I also found this report from 2012 at the f5.com site (now protected by login, but I got it through Google cache)
我还在 f5.com 站点上找到了 2012 年的这份报告(现在受登录保护,但我是通过 Google 缓存获得的)
It is likely the proxy will not work unless you are running BIG-IP 11.1 and MySQL 5.1, which were the versions I tested against. The MySQL protocol has a habit of changing.
除非您运行 BIG-IP 11.1 和 MySQL 5.1(我测试过的版本),否则代理可能无法工作。MySQL 协议有变化的习惯。
I suggest you contact F5 Supportand confirm that you are using a supported combination of versions.
我建议您联系F5 支持并确认您使用的是受支持的版本组合。
回答by Benoit Duffez
My case was that the server didn't accept the connection from this IP. The server is a SQL server from Google Apps Engine, and you have to configure allowed remote hosts that can connect to the server.
我的情况是服务器不接受来自该 IP 的连接。服务器是来自 Google Apps Engine 的 SQL 服务器,您必须配置允许连接到服务器的远程主机。
Adding the (new) host to the GAE admin page solved the issue.
将(新)主机添加到 GAE 管理页面解决了该问题。
回答by Rhenan Bartels
I've struggled a lot with this error. Tried every single answer I found on the internet.
我在这个错误上挣扎了很多。尝试了我在互联网上找到的每一个答案。
In the end, I've connected my computer to my cell phone's hotspot and everything worked. I turned out that my company's internet was blocking the connection with MySQL.
最后,我将电脑连接到手机的热点,一切正常。我发现我公司的互联网阻止了与 MySQL 的连接。
This is not a complete solution, but maybe someone faces the same problem. It worths to check the connection.
这不是一个完整的解决方案,但也许有人面临同样的问题。值得检查连接。
回答by Henry
I solved this by stopping mysql several times.
我通过多次停止 mysql 解决了这个问题。
$ mysql.server stop
Shutting down MySQL
.. ERROR! The server quit without updating PID file (/usr/local/var/mysql/xxx.local.pid).
$ mysql.server stop
Shutting down MySQL
.. SUCCESS!
$ mysql.server stop
ERROR! MySQL server PID file could not be found! (note: this is good)
$ mysql.server start
All good from here. I suspect mysql had been started more than once.
从这里一切都很好。我怀疑 mysql 已经启动了不止一次。
回答by Rose
I use several mysql connections (connecting to different sets of databases) in localhost.
我在本地主机中使用了几个 mysql 连接(连接到不同的数据库集)。
This happened to me after I shut my computer down and mysql was not properly shutdown. After starting my machine I was able to successfully connect to multiple db connections except one (I used this a lot before my machine shutdown). As per the instructions in this posts I doubled connect_timeout but I was not able to connect to that one database connection.
在我关闭计算机并且 mysql 没有正确关闭后,这发生在我身上。启动我的机器后,我能够成功连接到多个数据库连接,除了一个(我在机器关闭之前经常使用它)。根据这篇文章中的说明,我将 connect_timeout 加倍,但我无法连接到那个数据库连接。
I restarted my machine and i can successfully connect now. This will help you unblock yourself but it'd be great if it can be fixed without restarting the machine.
我重新启动了我的机器,我现在可以成功连接了。这将帮助您解锁自己,但如果可以在不重新启动机器的情况下修复它,那就太好了。
Another concern is: connection_timeout seemed to me delay related problem but I was getting the error immediately in localhost when there is no network in the equation.
另一个问题是:connection_timeout 在我看来与延迟相关的问题,但是当方程中没有网络时,我立即在 localhost 中收到错误消息。
回答by Richardhe2007
In my case, it happened when there were a lot of connection to the MySQL server (15,000 connections) and the free memory was about 120M . After I added more memory to the server, the error was gone.
就我而言,它发生在有大量连接到 MySQL 服务器(15,000 个连接)并且可用内存约为 120M 时。在我向服务器添加更多内存后,错误消失了。
回答by Blade1024
Another possibility can be connection reset from the TCP wrappers (/etc/hosts.deny and /etc/hosts.allow). Just check what is coming in from the telnet to port 3306 - if it is nothing, then there is something is in the middle preventing communication from happening.
另一种可能性是从 TCP 包装器(/etc/hosts.deny 和 /etc/hosts.allow)重置连接。只需检查从 telnet 到端口 3306 的内容 - 如果什么都没有,那么中间有什么东西阻止了通信的发生。
回答by elad silver
I have a mac but would assume all linux are the same for this part...
我有一台 mac 但我会假设所有的 linux 都是一样的...
In my case I got this:
就我而言,我得到了这个:
2018-12-03 11:13:27 - Start server:
2018-12-03 11:13:27 - Server start done.
2018-12-03 11:13:27 - Checking server status...
2018-12-03 11:13:27 - Trying to connect to MySQL...
2018-12-03 11:13:27 - Lost connection to MySQL server at 'reading authorization packet', system error: 0 (2013)
2018-12-03 11:13:27 - Assuming server is not running
I ran this:
我跑了这个:
sudo killall mysqld
And then started the mysql again through mysqlworkbench although in your case it might be like this:
然后通过 mysqlworkbench 再次启动 mysql 虽然在你的情况下它可能是这样的:
mysql.server start
*sidenote: I tried running mysql.server stop
and got this Shutting down MySQL
.... SUCCESS!
but after running ps aux | grep mysql
I saw that it hasn't really shut down...
*旁注:我尝试运行mysql.server stop
并得到了这个,Shutting down MySQL
.... SUCCESS!
但运行后ps aux | grep mysql
我发现它并没有真正关闭......
回答by feelthhis
I got both errors: mostly reading initial communication packet
andreading authorization packet
one time. It seems random, but sometimes I was able to establish a connection after reboots, but after some timethe error creeped back.
我得到了两个错误:主要是reading initial communication packet
和reading authorization packet
一个时间。这似乎是随机的,但有时我能够在重新启动后建立连接,但一段时间后错误又回来了。
Avoiding the 5GHz WiFi in the client seems to have fixed the issue.That's what worked for me (server was always connected to 2.4GHz).
避免客户端中的 5GHz WiFi 似乎已经解决了这个问题。这对我有用(服务器始终连接到 2.4GHz)。
I tried everything from server versions, odbc connector versions, firewall settings, installing some windows update (and then uninstalling them), some of the answers posted here, etc... lost my entire sleep time for today. Super tired day awaits me.
我尝试了从服务器版本、odbc 连接器版本、防火墙设置、安装一些 Windows 更新(然后卸载它们)、这里发布的一些答案等的所有内容……今天我失去了整个睡眠时间。超级累的一天等着我。