ããå¦æä½ æ²¡æä¿®æ¹è¿MySQLçé
ç½®ï¼ç¼ºçæ
åµä¸ï¼wait_timeoutçåå§å¼æ¯28800ã
ããwait_timeout è¿å¤§æå¼ç«¯ï¼å
¶ä½ç°å°±æ¯MySQLé大éçSLEEPè¿ç¨æ æ³åæ¶éæ¾ï¼æ累系ç»æ§è½ï¼ä¸è¿ä¹ä¸è½æè¿ä¸ªæ设置çè¿å°ï¼å¦åä½ å¯è½ä¼ééå°âMySQL has gone awayâä¹ç±»çé®é¢ï¼é常æ¥è¯´ï¼æè§å¾æwait_timeout设置为10æ¯ä¸ªä¸éçéæ©ï¼ä½æäºæ
åµä¸å¯è½ä¹ä¼åºé®é¢ï¼æ¯å¦è¯´æä¸ä¸ªCRONèæ¬ï¼ å
¶ä¸ä¸¤æ¬¡SQLæ¥è¯¢çé´éæ¶é´å¤§äº10ç§çè¯ï¼é£ä¹è¿ä¸ªè®¾ç½®å°±æé®é¢äºï¼å½ç¶ï¼è¿ä¹ä¸æ¯ä¸è½è§£å³çé®é¢ï¼ä½ å¯ä»¥å¨ç¨åºéæ¶ä¸æ¶mysql_pingä¸ä¸ï¼ 以便æå¡å¨ç¥éä½ è¿æ´»çï¼éæ°è®¡ç®wait_timeoutæ¶é´ï¼ï¼
ãã# vi /etc/my.cnf
ãã[mysqld]
ããwait_timeout=10
ãã# /etc/init.d/mysql restart
ããä¸è¿è¿ä¸ªæ¹æ³å¤ªç硬äºï¼çº¿ä¸æå¡éå¯æ 论å¦ä½é½åºè¯¥å°½å¯è½é¿å
ï¼ççå¦ä½å¨MySQLå½ä»¤è¡ééè¿SETæ¥è®¾ç½®ï¼
ããmysql> set global wait_timeout=10;
ããmysql> show global variables like 'wait_timeout';+----------------------------+-------+
ãã| Variable_name | Value |
ãã+----------------------------+-------+
ãã| wait_timeout | 10 |+----------------------------+-------+
ããè¿ éä¸ä¸ªå®¹ææ人æèçå°æ¹æ¯å¦ææ¥è¯¢æ¶ä½¿ç¨çæ¯show variablesçè¯ï¼ä¼åç°è®¾ç½®å¥½å并没æçæï¼è¿æ¯å 为å纯使ç¨show variablesçè¯å°±çåäºä½¿ç¨çæ¯show session variablesï¼æ¥è¯¢çæ¯ä¼è¯åéï¼åªæ使ç¨show global variablesï¼æ¥è¯¢çææ¯å
¨å±åéã
ããç½ç»ä¸å¾å¤äººé½æ±æ¨è¯´ä»ä»¬set globalä¹å使ç¨show variablesæ¥è¯¢æ²¡æåç°æ¹åï¼åå å°±å¨äºæ··æ·äºä¼è¯åéåå
¨å±åéï¼å¦æä»
ä»
æ³ä¿®æ¹ä¼è¯åéçè¯ï¼å¯ä»¥ä½¿ç¨ç±»ä¼¼set wait_timeout=10;æè
set session wait_timeout=10;è¿æ ·çè¯æ³ã
ããå¦ä¸ä¸ªå¼å¾æ³¨æçæ¯ä¼è¯åéwait_timeoutåå§åçé®é¢ï¼è¿ä¸ç¹å¨æåéå·²ç»æç¡®æåºäºï¼æå°±ç´æ¥æ·è´äºï¼
ããOn thread startup, the session wait_timeout value is initialized from the global wait_timeout value or from the global interactive_timeout value, depending on the type of client (as defined by the CLIENT_INTERACTIVE connect option to mysql_real_connect()).
ããMySQL大æ¿Jeremy Zawodnyæ¾å¨ä»çæç« Fixing Poor MySQL Default Configuration Valueséé¢ååºäºå 个å¾æ¶å¿çMySQL缺ç设置ï¼ä¸è¿æ²¡å
å«wait_timeoutï¼ä½æè§å¾å®ä¹åºè¯¥ç®ä¸ä¸ªï¼æ¯æ¬¡æ°è£
MySQLåæ好é½è®°å¾ä¿®æ¹å®ã
温馨提示:答案为网友推荐,仅供参考