I am trying to do a mysql dump via php.
This is the code
$backupFile = $table. "-". date("Y-m-d-H:i:s") . '.gz';
//Command nog aanpassen....
$command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $dbname | gzip > $backupFile";
//$status = system($command);
echo $backupFile ."<br>";
$status = passthru($command, $a);
echo "output:" . $a;
The value of $a = 2. But I can’t find what it means. I also can’t find the backup file anywhere.
Any idea’s?
I’m not sure if this is the problem, but it looks like your password passing parameter is incorrect.
If you use -p you need to have the password right next to it, without whitespace, like so:
Or use the long –password=$dbpass.
For example:
From the mysqldump man page: