开发者

mysql server has gone away - not timeout error or crash

开发者 https://www.devze.com 2023-03-13 01:02 出处:网络
I\'m using WAMP (Apache 2.2.11, MySQL 5.1.36, PHP 5.3.0) to write a PHP web application that has a link to a MySQL database.

I'm using WAMP (Apache 2.2.11, MySQL 5.1.36, PHP 5.3.0) to write a PHP web application that has a link to a MySQL database.

I run a procedure that takes about 2 minutes in Toad to execute. If i try to run it in the PHP application, i got the errors "MySQL server has gone away in...", "Error reading result set's header", 开发者_C百科and "maximum execution time of 60 seconds exceeded"

I upped mysql.connect_timeout to 600 (using ini_set) and default_socket_timeout to 600 (as suggested in this question. This solved the timeout error, but i still get the first two.

I tried setting max_input_time to -1, and on the MySQL server side, i upped max_allowed_packet to 256M. Neither of these solved the problem.

Are there any other ways to bypass this error without altering the MySQL procedure being run?

when the webpage is loaded:

set_time_limit(0);
ini_set('mysql.connect_timeout', 600);//for long queries
ini_set('default_socket_timeout', 600);//for long queries
//ini_set('max_input_time',-1); //don't know what this does

when a query is called:

if($reconnect===true){
  $this->disconnectDB();
}
$this->connectToDB();
if($this->selectDB($dbName)===FALSE){
  return false;
}
if(mysql_ping($this->con)===false){
  return array();           
}
$result = mysql_query($query,$this->con); //this is where the connection "goes away"


This is the result of a PHP setting: maximum execution time of 60 seconds exceeded. Put set_time_limit(0) to disable the time limit when you need to.

MySQL server has gone away in... can be the result of several things. Including a MySQL crash. You may want to look at mysql logs for clues.

0

精彩评论

暂无评论...
验证码 换一张
取 消