MySQL is automatically reconnected after being disconnected

Source: Internet
Author: User
Tags mysql command line

 

Solution

After mysql_real_connect is used for connection

Char reconnectarg =
1;

Mysql_options (mconn,
Mysql_opt_reconnect, (char
*) & Reconnectarg );

 

How to test

MySQL configuration file my. the configuration item wait_timeout = 1 (eight hours by default) is added under section [mysqld] of INI. This configuration item means that MySQL will be automatically disconnected if the connection between 1 s and MySQL is not active.

After it takes effect, the MySQL command line connects to the MySQL database and performs various MySQL operations to see if any of the operations failed.

The test versions include 5.1.34 and 5.0.15.

Related functions

Mysql_ping

Check whether MySQL is disconnected. If yes, try again.

 

Mysql_pconnect

Ensure that the MySQL service does not close the MySQL connection

References

MySQL persistent connection

Pasted
From

 

MySQL automatic Reconnection

Pasted
From

 

 

 

 

 

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.