MySQL Server has Gone Away - Exactly in 60 Seconds
In this scenario, a MySQL query that was previously running successfully is now experiencing a timeout after 60 seconds, displaying the error "MySQL server has gone away." The issue persists even though the wait_timeout variable has been adjusted.
Analysis:
The fact that the timeout occurs precisely at 60 seconds suggests that a setting rather than limited resources is the cause. This is supported by the observation that running the same query directly from a MySQL client is successful.
Solution:
The root cause of the problem is the PHP option mysql.connect_timeout. This option determines the time the PHP client waits for the first response from the MySQL server, not just the connection timeout.
To resolve the issue, increase the value of mysql.connect_timeout as follows:
ini_set('mysql.connect_timeout', 300);
ini_set('default_socket_timeout', 300);
Explanation:
By increasing the value of mysql.connect_timeout, you extend the time PHP waits for the server's initial response, allowing the query to execute fully within the 60-second window.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3