Home > Backend Development > PHP Tutorial > Why Does MySQL Server Fade Away Precisely in 60 Seconds?

Why Does MySQL Server Fade Away Precisely in 60 Seconds?

Mary-Kate Olsen
Release: 2024-10-18 22:03:30
Original
697 people have browsed it

Why Does MySQL Server Fade Away Precisely in 60 Seconds?

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:

<code class="php">ini_set('mysql.connect_timeout', 300);
ini_set('default_socket_timeout', 300); </code>
Copy after login

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.

The above is the detailed content of Why Does MySQL Server Fade Away Precisely in 60 Seconds?. For more information, please follow other related articles on the PHP Chinese website!

source:php
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template