尝试运行一个简单的备份脚本,它只打印错误消息。我做错了什么吗?这是完整的代码。我在 linux 上并且可以完全访问数据库。
它只打印“您的系统出现问题,导致备份无法完成”
<?php
$dbhost = "localhost"; // usually localhost
$dbuser = "myuser";
$dbpass = "mypass";
$dbname = "mydb";
$sendto = "Webmaster <webmaster@mydomain.com>";
$sendfrom = "Automated Backup <info@mydomain.com>";
$sendsubject = "Daily Mysql Backup";
$bodyofemail = "Here is the daily backup.";
$headers = 'My Shop <myname@mydomain.com>' . "\n";
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n";
$backupfile = $dbname . date("Y-m-d") . '.sql';
if(system("mysqldump -h $dbhost -u $dbuser -p$dbpass $dbname > $backupfile")){
mail('receiver@yahoo.com','Back Up Service','Back Up successfully completed',$headers );
echo'Back up saved successfully.';
}else {
echo'There was an issue with your system that prevented the backup from completing';
}
?>
谢谢你的帮助。