Click to See Complete Forum and Search --> : change mysql timeout variable


crz_06
12-06-2005, 05:48 AM
I'm trying to import a large sql database, but keep getting '"Fatal error: Maximum execution time of 300 seconds exceeded' warning in phpmyadmin. So i cannot import my database

'Server variables and settings' of phpinfo show the 'delayed insert timeout' is the default value of 300. How and where do i change this value to say 900. (don't know command line mysql).

I allready change httpd.conf variable 'Timeout 300' to 'Timeout 30000' but no effect. Also setting 'max_execution_time' in php.ini doesn't prevent the error message from showing. I restarted apache on every change. The only variables of 300 I can imagine and see listed in phpinfo are HTTP_KEEP_ALIVE and the afore mentioned mysql 'delayed insert timeout'

PS: I tried cutting up the sql in smaller pieces, but the texteditor i'm using (Jedit) right now gives me a memory error when opening the 68 mb .sql file. Anyone knows a proper text editor that can handle large text files.

ShrineDesigns
12-06-2005, 02:03 PM
for an sql file of that size you should use the mysql-dump command if possible

phpmyadmin can not handle sql files that large, you can try my import/export class, but i think you'll run into the same problems<?php
class sql_data
{
var $data;
var $id;

function comment($str)
{
$str = wordwrap($str, 54, "\n");
$c = preg_split("/[\r\n]+/s", $str);
$r = '';

foreach($c as $s)
{
$r .= "-- $s\n";
}
return $r;
}
function export($tables_to_export, $data_only = false, $file = NULL)
{
foreach($tables_to_export as $t)
{
$data = '';

if(!$data_only)
{
$res = @mysql_query("SHOW CREATE TABLE `$t`");
$data .= "-- --------------------------------------------------------\n\n";
$data .= $this->comment("\nTable structure for table `$t`\n") . "\n";
list( , $dump) = @mysql_fetch_array($res, MYSQL_NUM);
$data .= $dump . ";\n\n";
@mysql_free_result($res);
}
$res = @mysql_query("SELECT * FROM `$t`");
$data .= $this->comment("\nDumping data for table `$t`\n") . "\n";

while($row = @mysql_fetch_array($res, MYSQL_NUM))
{
while(list($k, $v) = each($row))
{
$row[$k] = addslashes($v);
}
$data .= "INSERT INTO `$t` VALUES ('" .implode("', '", $row). "');\n";
}
@mysql_free_result($res);
$this->data .= $data;
}
if(!$file)
{
return $this->data;
}
else
{
$fp = @fopen($file, 'wb');
@fwrite($fp, $this->data);
@fclose($fp);
}
}
function import($file, $data_only = false)
{
if(!file_exists($file))
{
die('sql_data::import() error, file: ' .$file. ' does not exist.');
}
$fp = @fopen($file, 'rb');
$this->data = @fread($fp, @filesize($file));
@fclose($fp);
$this->uncomment();

$this->data = preg_split("/;\Z/m", $this->data, NULL, PREG_SPLIT_NO_EMPTY);

for($i = 0; $i < count($this->data); $i++)
{
$this->data[$i] = trim($this->data[$i]);

if(($data_only && preg_match("/CREATE TABLE/i", $this->data[$i])) || empty($this->data[$i]))
{
unset($this->data[$i]);
}
parent::query($this->data[$i]);
}
return mysql_affected_rows();
}
function uncomment()
{
return preg_replace("/^(?:\#|\-+).*\Z/m", '', $this->data);
}
function sql_data($server, $username, $password, $database)
{
$this->id = @mysql_connect($server, $username, $password);

if(!$this->id || !@mysql_select_db($database, $this->id))
{
die('unable to connect to database');
}
}
}
?>example$sql = new sql_data('localhost', 'root', '', 'db');
$sql->import('path/to/data.sql', 0); // imports data and structure
$sql->import('path/to/data.sql', 1); // imports data only