Home > Database > Mysql Tutorial > body text

ERROR 2013 (HY000): Lost connection to MySQL server at ‘rea_MySQL

WBOY
Release: 2016-06-01 13:51:24
Original
1140 people have browsed it

当WEB服务器负载高的时候,经常会出现这种错误,

原因:

MySQL默认connect_timeout是5秒,超过了这个时间MySQL的server端就会返回“Bad handshake”。

解决办法:

1.大多数时候设置"set global connect_timeout=60"是可以解决问题的;

我们可以通过执行“SHOW STATUS LIKE 'aborted%'”,可以观察到
Variable_name Value
Aborted_clients 6
Aborted_connects 15010

觉得是否要增加connect_timeout的时间,"Aborted_connects"将会随着服务端放弃客户端初始连接而增加。如果"Aborted_connects"很大,并且不断增加,就需要增加"connect_timeout".

2.在MySQL的配置文件中[mysqld]添加"skip-name-resolve",减少域名解析的时间

3.部署服务器端的网络要好,至少大于100Mbps/s

4.如果是在调用mysql_query的时候出现的问题,那就需要把"net_read_timeout"的时间调成30秒,或者60秒,或者更大的值

5.如果还不能解决问题,那估计是你的SQL语句中含有BLOB这种大类型,我们就需要增加"max_allowed_packet"的值了

参考资料:

http://dev.mysql.com/doc/refman/5.0/en/error-lost-connection.html

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!