{"id":263,"date":"2014-04-28T20:40:42","date_gmt":"2014-04-28T20:40:42","guid":{"rendered":"https:\/\/qbytes.cloud\/?p=263"},"modified":"2014-04-28T20:40:42","modified_gmt":"2014-04-28T20:40:42","slug":"mysqls-wait_timeout-and-interactive_timeout-variables","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2014\/04\/28\/mysqls-wait_timeout-and-interactive_timeout-variables\/","title":{"rendered":"MySQL&#8217;s wait_timeout and interactive_timeout Variables"},"content":{"rendered":"<p>Ever get these errors?<\/p>\n<p>Mysql reporting error when accessing plesk. Zend_Db_Adapter_Exception: SQLSTATE[08004] [1040] Too many connections.<\/p>\n<p>You can set-variable=max_connections=250 to \/etc\/my.cnf and restart and use mysql close statements for php code. <\/p>\n<p>Or, set up mysql to close sleeping processes.<\/p>\n<p>Mysql Config. (\/etc\/my.cnf)<br \/>\nwait_timeout variable represents the amount of time that MySQL will wait before killing an idle connection.<br \/>\nThe default wait_timeout variable is 28800 seconds, which is 8 hours. That&#8217;s a lot.<\/p>\n<p>Sometimes, putting wait_timeout too low (e.g. 30, 60, 90) can result in MySQL has gone away error messages. You&#8217;ll have to decide for your configuration.<\/p>\n<p>How to change it.<\/p>\n<p>Step 1) Edit your \/etc\/my.cnf file and enter the following 2 values.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\n&#x5B;mysqld]\ninteractive_timeout=300\nwait_timeout=300\n\n<\/pre>\n<p>Step 2) run the command and enter your root password<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\nmysql -uroot -p -e&quot;SET GLOBAL wait_timeout=300; SET GLOBAL interactive_timeout=300;&quot;\n\n<\/pre>\n<p>If you are connected from the mysql console<br \/>\ne.g. mysql> you can run this command which will show you global and session variables.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\nSELECT @@global.wait_timeout, @@global.interactive_timeout, @@session.wait_timeout, @@session.interactive_timeout;\n\n+-----------------------+------------------------------+------------------------+-------------------------------+\n| @@global.wait_timeout | @@global.interactive_timeout | @@session.wait_timeout | @@session.interactive_timeout |\n+-----------------------+------------------------------+------------------------+-------------------------------+\n|                   300 |                          300 |                  28800 |                         28800 |\n+-----------------------+------------------------------+------------------------+-------------------------------+\n1 row in set (0.00 sec)\n\n<\/pre>\n<p>To see the the current values you can run this command<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\nmysql&gt; show global variables like &#039;%timeout%&#039;;\n\n+----------------------------+----------+\n| Variable_name              | Value    |\n+----------------------------+----------+\n| connect_timeout            | 10       |\n| delayed_insert_timeout     | 300      |\n| innodb_lock_wait_timeout   | 50       |\n| innodb_rollback_on_timeout | OFF      |\n| interactive_timeout        | 300      |\n| lock_wait_timeout          | 31536000 |\n| net_read_timeout           | 30       |\n| net_write_timeout          | 60       |\n| slave_net_timeout          | 3600     |\n| wait_timeout               | 300      |\n+----------------------------+----------+\n10 rows in set (0.00 sec)\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Ever get these errors? Mysql reporting error when accessing plesk. Zend_Db_Adapter_Exception: SQLSTATE[08004] [1040] Too many connections. You can set-variable=max_connections=250 to \/etc\/my.cnf and restart and use mysql close statements for php code. Or, set up mysql to close sleeping processes. Mysql Config. (\/etc\/my.cnf) wait_timeout variable represents the amount of time that MySQL will wait before killing &#8230; <a title=\"MySQL&#8217;s wait_timeout and interactive_timeout Variables\" class=\"read-more\" href=\"https:\/\/www.qbytes.cloud\/index.php\/2014\/04\/28\/mysqls-wait_timeout-and-interactive_timeout-variables\/\" aria-label=\"Read more about MySQL&#8217;s wait_timeout and interactive_timeout Variables\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[70],"tags":[],"class_list":["post-263","post","type-post","status-publish","format-standard","hentry","category-mysql"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/263","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=263"}],"version-history":[{"count":0,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/263\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=263"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=263"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}