修复错误 mysql 服务器已消失

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15112588/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 16:41:28  来源:igfitidea点击:

Fix error mysql server has gone away

mysql

提问by cogabh

My VPS very often fails to "MySQL server has gone away (error 2006)"and loses connection. I have increased the value of the variable in my.cnf but the condition did not improve. Here is my.cnf:

我的 VPS 经常失败“MySQL 服务器已经消失(错误 2006)”并失去连接。我已经增加了 my.cnf 中变量的值,但情况没有改善。这是我的.cnf:

[mysqld]
port            = 3306
socket          = /var/lib/mysql/mysql.sock
default-storage-engine=myisam
datadir=/var/lib/mysql
old_passwords=1
skip-bdb
skip-innodb
max_allowed_packet = 256M
table_cache= 512M
wait_timeout = 180
max_connections = 2000
net_read_timeout= 180
query_cache_size = 512M
query_cache_limit = 512M
max_user_connections=300

[client] 
socket=/var/lib/mysql/mysql.sock
max_allowed_packet = 128M
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

回答by Andy Refuerzo

Increase your wait_timeoutand net_read_timeoutto something bigger than 180sec (3mins) like 3600sec if there are some queries that takes longer or if you are getting results sets that are really big. You may also want to increase max_allowed_packetto something bigger than 256M if your result sets are really big.

如果有一些查询需要更长的时间或者如果您得到的结果集非常大,则将您的wait_timeoutnet_read_timeout增加到大于 180 秒(3 分钟)的值,例如 3600 秒。max_allowed_packet如果您的结果集非常大,您可能还想增加到大于 256M 的大小。