我从压缩的mysql下载数据库时遇到问题。它有一个很大的尺寸,为什么我要压缩它。这是我在gzip中使用php从mysql下载数据库的代码。但它下载了一个损坏的文件。
$filename = "backup" . date("YmdHis") . ".sql.gz";
$db_host = "localhost";
$db_username = "root";
$db_password = "";
$db_database = "movies";
$dir = "path/to/file/";
$cmd = "mysqldump -h {$db_host} -u {$db_username} --password={$db_password} {$db_database} | gzip > {$dir}{$filename}";
exec($cmd);
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"$filename\"");
passthru("cat {$dir}{$filename}");