How to troubleshoot MySQL database x hours without connection auto-shutdown

Source: Internet
Author: User

Open My.ini under Windows, add:

interactive_timeout=28800000

wait_timeout=28800000

Expert answer: MySQL is a small relational database management system, because of MySQL small size, speed, low total cost of ownership, especially the characteristics of open source, many small and medium-sized websites in order to reduce the total cost of ownership of the site MySQL as the site database. About MySQL auto-shutdown, you can adjust the connection parameters via MySQL server-side program MySQL administrator. Adjust the max_connections max_updates max_questions three data to a very large number, then your limited operation will not result in the termination of the database service in the MySQL database, if a connection 8 hours without request and operation, will automatically disconnect, This results in errors in some database-based connection applications, especially WEB applications.

Three ways to resolve the MySQL database auto-shutdown service:

Method One: The name of this parameter is Wait_timeout, and its default value is 28,800 seconds (8 hours). Its meaning is to close a connection before the number of seconds in this connection to action, that is, if a connection is idle more than the number of seconds set by this option, MySQL will actively disconnect the connection.

Modify the operation:

Under Linux open/etc/my.cnf, add the following parameters under attribute group mysqld:

[Mysqld]

interactive_timeout=28800000

wait_timeout=28800000

Open My.ini under Windows, add:

[Mysqld]

interactive_timeout=28800000

wait_timeout=28800000

Practice has shown that there is no way to set this value to infinity, that is, permanent.

Therefore, if you cannot guarantee that your application will have at least one operation in the set number of seconds, it is best to solve this problem with a second method.

Method Two: Modify the following JDBC Connection URL:

Dbc:mysql://hostaddress:3306/schemaname?autoreconnect=true add autoreconnect=true This parameter, that can solve the problem.

Method Three: Configuration file (Proxool.xml):

......

Experts recommend that MySQL automatically shut down the service three methods, the user best to take the first approach to the most thorough solution.

How to troubleshoot MySQL database x hours without connection auto-shutdown

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.