修复错误mysql服务器已消失 [英] Fix error mysql server has gone away
问题描述
我的VPS通常无法"MySQL服务器已消失(错误2006)" ,并且失去连接.我增加了my.cnf中变量的值,但条件没有改善.这是my.cnf:
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:
[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
推荐答案
如果某些查询需要更长的时间或获得结果,则将wait_timeout
和net_read_timeout
增大到大于3600sec的180sec(3分钟),例如3600sec.真的很大如果结果集很大,您可能还想将max_allowed_packet
增大到大于256M.
Increase your wait_timeout
and net_read_timeout
to 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_packet
to something bigger than 256M if your result sets are really big.
这篇关于修复错误mysql服务器已消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!