For whoever he helped, I used Eddie's answer and changed it for my own purposes (outputting a MySQL dump file without flooding the server RAM)
$dumpCommand = "mysqldump --skip-lock-tables -u $dbuser -p$dbpasswd $dbname"; $dumpFileName = 'backup_'.$dbname.'-'.date('Ymd-Hi').'.sql'; $descriptorSpec = array( 0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "a") ); $pipes = array(); $process = proc_open($dumpCommand, $descriptorSpec, $pipes, null, null); if(!is_resource($process)) { die('Unable to start process'); } header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="'.$dumpFileName.'"'); do { echo fgets($pipes[1]); // Will wait for EOL $arrStatus = proc_get_status($process); } while($arrStatus['running']); fclose($pipes[0]); fclose($pipes[1]); fclose($pipes[2]); proc_close($process);
source share