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