我想按下按钮单击使用下面的代码,每次点击我得到空数据库备份。我试过所有的文章,但结果是一样的。可以帮助我解决这个问题。Mysql数据库备份按钮点击在php
<?php
ob_start();
$username = "root";
$password = "";
$hostname = "localhost";
$dbname = "cars";
$command = "D:\\..\\wamp64\\bin\\mysqldump --add-drop-table host=$hostname
--user=$username ";
if ($password)
$command.= "--password=". $password ." ";
$command.= $dbname;
system($command);
$dump = ob_get_contents();
ob_end_clean();
// send dump file to the output
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($dbname . "_" .
date("Y-m-d_H-i-s").".sql"));
flush();
echo $dump;
exit();
?>
你需要转储到一个文件,然后放进了丘陵地 – nogad