How To Enable/ Disable Auto Reconnect in MySQL ÇÏ´Â ¹æ¹ýÀ» Ȱ¼ºÈ / ºñȰ¼ºÈ mysql ÀÚµ¿ À翬°á¿¡¼

What is auto reconnect in MySQL? mysql ÀÚµ¿ À翬°áÀÌ ¹«¾ùÀԴϱî?
The MySQL client library can perform an automatic reconnect to the server if it finds that the connection is down when you attempt to send a statement to the server to be executed. the mysql Ŭ¶óÀÌ¾ðÆ® ¶óÀ̺귯¸®¸¦ ÀÚµ¿À¸·Î ´Ù½Ã ¿¬°áÀ» ¼öÇàÇÒ ¼öÀÖ½À´Ï´Ù°¡ ¹ß°ßÇÏ´Â °æ¿ì ¼¹ö·ÎÀÇ ¿¬°áÀº ¾Æ·¡¸¦ º¸³»´Â ¼º¸íÀ» ½ÃµµÇÒ ¶§ ¼¹ö¸¦ ½ÇÇàÇÕ´Ï´Ù. In this case, the library tries once to reconnect to the server and send the statement again. ÀÌ °æ¿ì¿¡´Â ¶óÀ̺귯¸®¸¦ ¼¹ö¿¡ ´Ù½Ã ¿¬°áÇÏ·Á°í ½Ãµµ¸¦ ÇÑ ¹ø ´·¯ ¹®ÀåÀ» ´Ù½Ã Àü¼ÛÇÕ´Ï´Ù.
Automatic reconnection can be convenient because you need not implement your own reconnect code, but if a reconnection does occur, several aspects of the connection state are reset and your application will not know about it. ÀÚµ¿À¸·Î ´Ù½Ã ¿¬°áÀ» ±¸ÇöÇÒ ¼öÀÖ½À´Ï´Ù Æí¸®ÇÑ ¿Ö³ÄÇÏ¸é ´ç½Å ÀÚ½ÅÀÇ ¿¬°á Äڵ带 Çʿ䰡 ¾ø´Ù,ÇÏÁö¸¸ ´Ù½Ã°¡ ¹ß»ýÇϸé, ¿©·¯ Ãø¸é¿¡ ¿¬°á »óŸ¦ ´Ù½Ã ¼³Á¤ÇÏ¿© ÀÀ¿ë ÇÁ·Î±×·¥°ú ±×°Í¿¡ ´ëÇØ ¾Ë ¼ö¾ø½À´Ï´Ù. This is extremely useful if you long running persistent connections to the database. À̰ÍÀº ¸Å¿ì ±ä °æ¿ì¿¡ À¯¿ëÇÕ´Ï´ÙÀ» µ¥ÀÌÅͺ£À̽º¿¡ ¿µ±¸ÀûÀÎ Á¢¼ÓÀ» ½ÇÇàÇÕ´Ï´Ù. Also if you have too many sql queries / use connection pool etc. auto reconnect is a handy feature. ¶ÇÇÑ ³Ê¹« ¸¹Àº °æ¿ì¿¡´Â sql °Ë»ö¾î / ¿¬°á Ç®¸µÀ» »ç¿ë µîµî ÀÚµ¿ À翬°áÀÌ Æí¸®ÇÑ ±â´ÉÀ»ÇÕ´Ï´Ù. Let's look at how to enable / disable auto reconnect in MySQL and what are the side-effects of enabling auto reconnect. ¸¦ Ȱ¼ºÈÇÏ´Â ¹æ¹ý¿¡ ´ëÇØ »ìÆìº¸°Ú / ÇØÁ¦ mysql ÀÚµ¿ À翬°á¿¡¼ ¿ì¸®´Â ¹«¾ùÀ» Ȱ¼ºÈ ¿· - ¿µÇâÀ» ÀÚµ¿ À翬°áÇÕ´Ï´Ù.
How to enable MySQL client auto reconnect mysql Ŭ¶óÀÌ¾ðÆ®¸¦ Ȱ¼ºÈÇÏ´Â ¹æ¹ý ÀÚµ¿ À翬°á
my_bool reconnect = 1; my_bool À翬°á = 1;
mysql_options(&mysql, MYSQL_OPT_RECONNECT, &reconnect); mysql_options (& mysql, mysql_opt_reconnect, & À翬°á);
What are the side-effects of MySQL auto reconnect? - ¿µÇâÀ» Ãø¸éÀº ¹«¾ùÀԴϱî mysql ÀÚµ¿ À翬°á?
- Any active transactions are rolled back and autocommit mode is reset. ¸ðµç Ȱ¼º Æ®·£Àè¼ÇÀÌ ·Ñ¹é ¹× autocommit ¸ðµå°¡¸¦ Àç¼³Á¤ÇÕ´Ï´Ù.
- All table locks are released. ¸ðµç Å×À̺íÀ» Àá±ÝÀÌ ÇØÁ¦ÇÕ´Ï´Ù.
- All TEMPORARY tables are closed (and dropped). ¸ðµç Àӽà Å×À̺íÀº Æó¼â (±×¸®°í Ç϶ô).
- Session variables are reinitialized to the values of the corresponding variables. ¼¼¼Ç º¯¼ö´Â ÇØ´ç º¯¼öÀÇ °ªÀ»À» ´Ù½Ã ÃʱâÈÇÕ´Ï´Ù. This also affects variables that are set implicitly by statements such as SET NAMES. ÀÌ ¶ÇÇÑ ¾Ï½ÃÀûÀ¸·Î ¿µÇâÀ» ¹ÌÄ¡´Â º¯¼ö°¡ÀÌ ¼³Á¤°ú °°Àº ¹®ÀåÀ¸·Î À̸§À» ¼³Á¤ÇÕ´Ï´Ù.
- User variable settings are lost. »ç¿ëÀÚ º¯¼ö ¼³Á¤ÀÌ ¼Õ½ÇÇÕ´Ï´Ù.
- Prepared statements are released. ÁغñµÈ ¸í·É¹®ÀÌ ÇØÁ¦ÇÕ´Ï´Ù.
- HANDLER variables are closed. 󸮱⠺¯¼ö°¡ Æó¼âÇÕ´Ï´Ù.
- The value of LAST_INSERT_ID() is reset to 0. ÀÇ °ªÀ» last_insert_id ()´Â ¸®¼ÂÀ» 0À¸·ÎÇÕ´Ï´Ù.
- Locks acquired with GET_LOCK() are released. Àá±Ý ÀåÄ¡¸¦ Ãëµæ get_lock ()°¡ Ãâ½ÃÇÕ´Ï´Ù.
- mysql_ping() does not attempt a reconnection if the connection is down. mysql_ping () ´Ù½Ã ¿¬°áÀ» ½ÃµµÇÏÁö ¾Ê½À´Ï´Ù ¿¬°áÀÌ °æ¿ì¿¡´Â ¾Æ·¡ÇÕ´Ï´Ù. It returns an error instead. ´ë½Å¿¡ ±×°Í¿¡ ¿À·ù¸¦ ¹ÝȯÇÕ´Ï´Ù.
How to disable MySQL client auto reconnect mysql Ŭ¶óÀÌ¾ðÆ® ÀÚµ¿ À翬°á ±â´ÉÀ» ÇØÁ¦ÇÏ´Â ¹æ¹ý
In view of the side-effects you may want to disable auto reconnect. - È¿°ú¸¦ º¼ ¼öÀÖ´Â Ãø¸é¿¡¼ »ç¿ëÇÏÁö ¾Êµµ·Ï ¼³Á¤ÇÒ ¼öÀÖ½À´Ï´Ù ÀÚµ¿ À翬°áÇÕ´Ï´Ù. In MySQL version 5.1 and above auto reconnect is disabled by default. mysql ¹öÀü 5.1 À̻󿡼 ÀÚµ¿ À翬°áÀº ±âº»ÀûÀ¸·Î »ç¿ëµÇÁö ¾Ê½À´Ï´Ù. In any version you can disable auto reconnect with the following PHP code: ¸ðµç ¹öÀü¿¡¼ ÀÚµ¿ ´Ù½Ã ¿¬°áÀ» ÇØÁ¦ÇÒ ¼öÀÖ½À´Ï´Ù ´ÙÀ½°ú °°Àº ÄÚµå :
my_bool reconnect = 0; my_bool À翬°á = 0;
mysql_options(&mysql, MYSQL_OPT_RECONNECT, &reconnect); mysql_options (& mysql, mysql_opt_reconnect, & À翬°á);
Filed under ¹Ø¿¡ Database µ¥ÀÌÅͺ£À̽º¸¦ , Enterprise Software ¿£ÅÍ ÇÁ¶óÀÌÁî ¼ÒÇÁÆ®¿þ¾î¸¦ , Headline News Çìµå ¶óÀÎ ´º½º , How To ÇÏ´Â ¹æ¹ýÀ» , Java Software ÀÚ¹Ù ¼ÒÇÁÆ®¿þ¾î , MySQL mysql , Open Source Software ¿ÀÇ ¼Ò½º ¼ÒÇÁÆ®¿þ¾î , PHP php , Programming ÇÁ·Î±×·¡¹Ö , RDBMS rdbms , Tech Note ±â¼ú Âü°í »çÇ× | |
| |
RSS 2.0 rss 2.0 | |
Trackback Æ®·¢¹é this Article | ÀÌ ¹®¼ |
Email this Article ÀüÀÚ ¿ìÆíÀÌ ¹®¼
You may also like to read °°Àº¸¦ ÀÐÀ» ¼öÀÖ½À´Ï´Ù |





































October 17th, 2007 at 1:25 pm 2007³â 10¿ù 17ÀÏ¿¡¼ ¿ÀÈÄ 1½Ã 25ºÐ
That¡¯s not PHP code ±×°Ô ¾Æ´Ï ÄÚµå
C/C++ perhaps. c / c + + ¾î¼¸éÇÕ´Ï´Ù.
October 18th, 2007 at 1:08 pm 2007³â 10¿ù 18ÀÏ¿¡¼ ¿ÀÈÄ 1½Ã 8ºÐ
It is PHP code. ÀÌ ÄÚµåÇÕ´Ï´Ù. Check the fine manual ÇÏ´ÃÀÇ ¹Ì¼¼ ¸Å´º¾ó
May 23rd, 2008 at 4:15 pm 2008³â 5¿ù 23ÀÏ¿¡¼ ¿ÀÈÄ 4½Ã 15ºÐ
There¡¯s no mysql_options() command listed anywhere in PHP documentation that I can find (trying to use it gives an ¡®undefined function¡¯ error). ÀÌ ¾ø¾î mysql_options () ¸í·ÉÀ» ³ª¿ ¾Æ¹« °÷À̳ª php ¹®¼¸¦ ãÀ» ¼öÀÖ¾î (±×°ÍÀ» »ç¿ëÇÏ·Á°í´Â 'Á¤ÀǵÇÁö ¾ÊÀº ±â´ÉÀ»'¿À·ù°¡ ¹ß»ýÇÕ´Ï´Ù). my_bool is definitely not a PHP variable type. my_bool´Â È®½ÇÈ÷ ¾Æ´Ï°í´Â php º¯¼ö¸¦ ÀÔ·ÂÇÕ´Ï´Ù. PHP variables also need $¡¯s, of which you have none. php º¯¼öµµ ÇÊ¿ä $ 'ÃÊ, Áß ´ç½ÅÀº ¾øÀ½. I¡¯m sorry, but this is NOT php code. Á˼ÛÇÏÁö¸¸, À̰ÍÀº ÄÚµåÇÕ´Ï´Ù.
You provide useful explanation of auto-reconnection functionality, but please don¡¯t mislead people by claiming it¡¯s useful code for PHP developers. ±ÍÇϰ¡ Á¦°øÇÑ À¯¿ëÇÑ ¼³¸íÀ» ÀÚµ¿ - ´Ù½Ã ¿¬°á ±â´É, »ç¶÷À» ¿ÀÇØÇÏÁö ¸¶½Ê½Ã¿À ÀÖ´Ù°í ÁÖÀåÇÏÁö¸¸ ±×°ÍÀº À¯¿ëÇÑ Äڵ带 php °³¹ßÀÚ¸¦ÇÕ´Ï´Ù.