MySQL 8-hour problems

Source: Internet
Author: User


After a period of time, the MySQL-based Web site will often be in a status that cannot respond, or the response is very slow, because the database connection is automatically closed. Run show variables like '% timeout %' in MySQL Command Line Client'
We can see two variables wait_timeout and interactive-timeout. Their default values are 28800 seconds, that is, 8 hours. That is to say, by default, Mysql will automatically close the opened connection after eight hours (28800 seconds) are not used. Www.2cto.com 1. to solve this problem, for versions earlier than MySQL5, such as Mysql4.x, you only need to modify the URL in the connection pool configuration and add a parameter: autoReconnect = true. For versions earlier than MySQL5, you need to modify my. cnf (or my. ini) file, after [mysqld]: wait_timeout = n interactive-timeout = n is the number of seconds waiting for activity before the server closes the interactive connection. Www.2cto.com 2. ruguoc3p0 connection pool solution <property name = "testConnectionOnCheckout" value = "false"/> <property name = "testConnectionOnCheckin" value = "false"/>
If the attribute is true, it can be solved. Because of high performance consumption, please use it only when needed. If it is set to true, the validity of each connection is verified when it is submitted. We recommend that you use idleConnectionTestPeriod or automaticTestTable to improve the connection test performance. <property name = "idleConnectionTestPeriod" value = "60"/> check the idle connections in all connection pools every several seconds, the default value is 0, indicating no check; <property name = "automaticTestTable" value = "c3p0_connection_testtable"/> chaunceyhao

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.