Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

MySQLΪʲô»áÓÐÒ»´ó¶ÑÔÚSleepµÄ½ø³Ì£¿

¹ØÓÚphpÓ¦¸ÃÔÚºÎʱµ÷ÓÃmysql_close()ÒÔ¼°pconnect·½Ê½ºÍ´«Í³·½Ê½ÓкÎÖÖÇø±ðÊÕ²Ø
ÒÔÇ°ÎÒÒ»Ö±ÈÏΪ£¬µ±phpµÄÒ³ÃæÖ´ÐнáÊøʱ£¬»á×Ô¶¯ÊͷŵôÒ»ÇС£ÏàÐźܶàÈ˶¼¸úÎÒÏëµÄÒ»Ñù¡£µ«ÊÂʵ֤Ã÷²¢²»ÊÇÕâÑù¡£±ÈÈçsession¾Í²»»áËæ×ÅÒ³ÃæÖ´ÐÐÍê±Ï¶øÊÍ·Å¡£
phpµÄÀ¬»ø»ØÊÕ»úÖÆ£¬ÆäʵֻÕë¶ÔÓÚphp±¾Éí¡£¶ÔÓÚmysql£¬phpûȨÀûÈ¥×Ô¶¯È¥ÊÍ·ÅËüµÄ¶«Î÷¡£Èç¹ûÄãÔÚÒ³ÃæÖ´ÐÐÍê±ÏÇ°²»µ÷ÓÃmysql_close()£¬ÄÇômysqlÄDZßÊDz»»á¹Ø±ÕÕâ¸öÁ¬½ÓµÄ¡£Èç¹ûÄãÊÇÓõÄÊÇpconnect·½Ê½£¬¼´Ê¹ÄãÔÚÒ³ÃæÖ´ÐÐÍê±ÏÇ°µ÷ÓÃmysql_close()£¬Ò²ÎÞ·¨Áímysql¹Ø±ÕÕâ¸öÁ¬½Ó¡£
Ò²ÐíÔÚ¸ºÔص͵ÄÇé¿öÏ£¬Äã¸ÐÊܲ»µ½Óкβ»Íס£ÏÂÃæÎÒ¾ÍÀ´½âÊÍÕâÁ½ÌìÎÒ¹Û²ì³öµÄÏÖÏó:
ÔÚphpÖÐʹÓÃpconnect·½Ê½½¨Á¢Á¬½Ó£¬È»ºóµ½mysql¿Í»§¶ËÏÂÖ´ÐÐshow processlist£»Èç¹ûÄãµÄ¸ºÔص½Ò»¶¨³Ì¶ÈµÄ»°£¬Äã¿ÉÒÔ¿´µ½ºÜ¶àsleepµÄ½ø³Ì£¬ÕâЩ½ø³Ì¾ÍÊÇÈËÃdz£ËµµÄËÀÁ¬½Ó£¬ËüÃÇ»áÒ»Ö±±£³Ösleep£¬Ö±µ½my.cnfÀïÃæÉèÖõÄwait_timeoutÕâ¸ö²ÎÊýÖµµÄʱ¼äµ½ÁË£¬mysql²Å»á×Ô¼ºÉ±ËÀËü¡£ÔÚɱËÀËüµÄʱºò£¬mysql»¹»áÔÚerror-logÀïÃæ¼Ç¼һÌõAborted connection xxx to db: 'xxx' user: 'xxx' host: 'xxx'µÄÈÕÖ¾£¬ÓÃgoogle·­Òëһϣ¬»áµÃµ½Ò»¸öÏ൱ǿº·µÄ½âÊÍ"Ì¥ËÀ¸¹ÖеÄÁ¬½Ó"!
ÄÇôÔì³ÉsleepµÄÔ­Òò£¬ÓÐÈý¸ö£¬ÏÂÃæÊÇmysqlÊÖ²á¸ø³öµÄ½âÊÍ:
1.¿Í»§¶Ë³ÌÐòÔÚÍ˳ö֮ǰûÓе÷ÓÃmysql_close().
2.¿Í»§¶ËsleepµÄʱ¼äÔÚwait_timeout»òinteractive_timeout¹æ¶¨µÄÃëÄÚûÓз¢³öÈκÎÇëÇóµ½·þÎñÆ÷.
3.¿Í»§¶Ë³ÌÐòÔÚ½áÊø֮ǰÏò·þÎñÆ÷·¢ËÍÁËÇëÇó»¹Ã»µÃµ½·µ»Ø½á¹û¾Í½áÊøµôÁË.
  
ÉÏÃæÊÇÎÒ¸ù¾ÝgoogleµÄ·­Òë¸ÄÁËÏ£¬¿ÉÄÜÓÐijЩµØ·½·­ÒëµÄ²»×¼È·¡£Ô­ÎÄÇë¼ûÏÂÃæ:
1 The client program did not call mysql_close() before exiting.
2 The client had been sleeping more than wait_timeout or interactive_timeout seconds without issuing any requests to the server.
3 The client program ended abruptly in the middle of a data transfer
Èç¹ûÄãµÄsleep½ø³ÌÊýÔÚͬһʱ¼äÄÚ¹ý¶à£¬ÔÙ¼ÓÉÏÆäËû״̬µÄÁ¬½Ó£¬×ÜÊý³¬¹ýÁËmax_connectionµÄÖµ£¬ÄÇmysql³ýÁËrootÓû§Í⣬¾ÍÎÞ·¨ÔÙ¼ÌÐø´¦ÀíÈκÎÇëÇóÎÞ·¨ÓëÈκÎÇëÇó½¨Á¢Á¬½Ó»òÕßÖ±½ÓdownÁË¡£ËùÒÔ£¬Õâ¸öÎÊÌâÔÚ´ó¸ºÔصÄÇé¿öÏ»¹ÊÇÏ൱ÑÏÖصġ£Èç¹û·¢ÏÖÄãµÄmysqlÓкܶàËÀÁ¬½Ó´æÔÚ£¬Ê×ÏÈÒªÏȼì²éÄãµÄ³ÌÐòÊÇ·ñʹÓõÄÊÇpconnectµÄ·½Ê½£¬Æä´Î£¬¼ì²éÔÚÒ³ÃæÖ´ÐÐÍê±ÏÇ°ÊÇ·ñ¼°Ê±µ÷ÓÃÁËmysql_close()£¬
»¹ÓÐÒ»¸ö°ì·¨£¬Äã¿ÉÒÔÔÚmy.


Ïà¹ØÎĵµ£º

MySQL²éѯÓÅ»¯¼¼ÊõϵÁн²×ù֮ʹÓÃË÷Òý£¨¶þ£©

 Ë÷ÒýµÄ´ú¼Û
¡¡¡¡Ò»°ãÀ´Ëµ£¬Èç¹ûMySQLÄܹ»ÕÒµ½·½·¨£¬ÀûÓÃË÷ÒýÀ´¸ü¿ìµØ´¦Àí²éѯ£¬Ëü¾Í»áÕâÑù×ö¡£Õâ
Òâζ×Å£¬¶ÔÓÚ´ó¶àÊýÇé¿ö£¬Èç¹ûÄãûÓжԱí½øÐÐË÷Òý£¬¾Í»áʹÐÔÄÜÊܵ½Ë𺦡£Õâ¾ÍÊÇÎÒËùÃè»æµÄË÷ÒýÓŵãµÄÃÀ¾°¡£µ«ÊÇËüÓÐȱµãÂð£¿Óеģ¬ËüÔÚʱ¼äºÍ¿Õ¼äÉ϶¼Óпª
Ïú¡£ÔÚʵ¼ùÖУ¬Ë÷ÒýµÄÓŵãµÄ¼ÛÖµÒ»°ã»á³¬¹ýÕâЩȱµã£¬µ«ÊÇÄ ......

Linux»·¾³MySQLµÄC±à³ÌÆð²½

Ê×ÏÈ°²×°±ØÐèµÄ¿ª·¢
°ü
sudo apt-get install gcc g++ libgcc1 libg++ make gdb
°²×°MYSQLµÄCÓïÑÔ¿ª·¢°ü
sudo apt-get install libmysql++-dev libmysql++2c2a libmysqlclient15-dev libmysqlclient15off
°ÑlibÎļþ¿½±´µ½¹«ÓÃ
sudo cp /usr/lib/mysql/* /usr/lib/
½¨Á¢Ò»¸öÐÂÎļþtest.cpp
vim test.cpp
ÊäÈëÄÚÈÝ
......

ʵÀý½²½âMySQLÁªºÏ²éѯ

 ÔÚ½²MySQLµÄJoinÓ﷨ǰ»¹ÊÇÏȻعËÒ»ÏÂÁª½áµÄÓï·¨£¬ºÇºÇ£¬ÆäʵÁ¬ÎÒ×Ô¼º¶¼ÍüµÃ²î²»¶àÁË£¬ÄǾʹó¼ÒÒ»ÆðÎÂÏ°°É£¨Èç¹ûÄÚÈÝÓдíÎó»òÓÐÒÉÎÊ£¬¹úÄÚ¹ØÓÚMySQLÁª½á²éѯµÄ×ÊÁÏÊ®·ÖÉÙ£¬ÏàÐÅ´ó¼ÒÔÚ¿´Á˱¾Îĺó»á¶ÔMySQLÁª½áÓï·¨ÓÐÏ൱ÇåÎúµÄÁ˽⣬Ҳ²»»á±»OracleµÄÍâÁª½áµÄ£¨“£«”ºÅ£©ÅªµÃºýÍ¿ÁË¡£
ÔÚSQL±ê×¼Öй滮µÄ£¨ ......

½÷·Àmysql maxContionTime(Á¬½Ó³¬Ê±) 8Сʱ¹¤×÷ÖÆ

1.½ñÌìµÄ³ÌÐò·¢²¼µ½·þÎñÆ÷£¬¹ýÁËÒ»Ííºó·¢ÏÖ³ÌÐò²»ÄÜ·ÃÎÊÁË£¬ºÃÏñÊÇÁ¬½Ó³ØÎÊÌâ¡£´íÎóÈçÏ£º [log4j:] 2009-10-30 17:32:10,353 - com.school.dao.OperaDAO -65984388 [http-8080-12] ERROR com.school.dao.OperaDAO  - find all failed
org.hibernate.exception.JDBCConnectionException: could not execute query ......

ÕÒ»ØmysqlÃÜÂë

 
ÐÞÕýһϣºÎÒÔÚWindowsϵÄʵ¼Ê²Ù×÷ÈçÏÂ
1.¹Ø±ÕÕýÔÚÔËÐеÄMySQL¡£
2.´ò¿ªDOS´°¿Ú£¬×ªµ½mysql\binĿ¼¡£
3.ÊäÈëmysqld½â --skip-grant-tables»Ø³µ¡£Èç¹ûûÓгöÏÖÌáʾÐÅÏ¢£¬ÄǾͶÔÁË¡£
4.ÔÙ¿ªÒ»¸öDOS´°¿Ú£¨ÒòΪ¸Õ²ÅÄǸöDOS´°¿ÚÒѾ­²»Äܶ¯ÁË£©£¬×ªµ½mysql\binĿ¼¡£
5.ÊäÈëmysql»Ø³µ£¬Èç¹û³É¹¦£¬½«³öÏÖMySQL ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ