How to solve the problem of automatic shutdown for mysql database without a connection for 8 hours _ MySQL

Source: Internet
Author: User
Enable my. ini in windows and add: interactive_timeout28800000wait_timeout28800000 expert answer: MySQL is a small relational database management system. MySQL is automatically disabled due to mysql volume.

Open my. ini in windows and add:

Interactive_timeout = 28800000

Wait_timeout = 28800000

Expert answer: MySQL is a small relational database management system. due to its small size, fast speed, and low total cost of ownership, especially open source code, many small and medium websites choose MySQL as their website database to reduce their total cost of ownership.

You can adjust the connection parameters through mysql Administrator, the mysql server program. Adjust max_connections max_updates max_questions to a large number. Therefore, your limited operations will not lead to the termination of the database service in the MySQL database, if a connection is not requested or operated for 8 hours, it will be automatically disconnected, resulting in some database-based connection applications, especially WEB applications, errors. There are three ways to automatically disable services for mysql databases:

Method 1: this parameter is named wait_timeout. its default value is 28800 seconds (8 hours ). It indicates the number of seconds that a connection will wait for to take action before closing a connection. that is to say, if a connection is idle more than the number of seconds set by this option, MySQL will take the initiative to disconnect the connection.

Modification operation:

In linux, open/etc/my. cnf and add the following parameters under the attribute group mysqld:

Interactive_timeout = 28800000

Wait_timeout = 28800000

Open my. ini in windows and add:

Interactive_timeout = 28800000

Wait_timeout = 28800000

Some practices have shown that there is no way to set this value to an infinitely large value, that is, permanent. Therefore, if you cannot guarantee that your application must have at least one operation in the specified number of seconds, you 'd better solve the problem using the second method.

Method 2: modify the URL of the following JDBC connection:

Jdbc: mysql: // hostaddress: 3306/schemaname? AutoReconnect = true

The parameter autoReconnect = true can solve this problem.

Method 3: configuration file (proxool. xml ):

Mysql

Jdbc: mysql: // localhost/yourDatebase? UseUnicode = true & characterEncoding = UTF-8

Com. mysql. jdbc. Driver

90000

20

3

20

3

True

True

SELECT CURRENT_USER

Experts suggest that you use the first method to solve the problem of automatically disabling mysql services.

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.