我似乎无法在 php 中恢复我的数据库备份。这是我的代码
<?php
$host = 'localhost';
$user = 'root';
$pass = ' ';
$dbname = 'itravel';
date_default_timezone_set('Asia/Kuala_Lumpur');
$date = date('Y_m_d');
if(isset($_POST['backup']))
{
$backup = "c:/xampp/mysql/bin/mysqldump --opt -h $host -u $user $dbname > itravel_backup_$date.sql";
system($backup);
}
if(isset($_POST['restore']))
{
$restore = "c:/xampp/mysql/bin/mysqldump --opt -h $host -u $user $dbname < itravel_backup_$date.sql";
system($restore);
}
?>
备份成功,但还原失败。帮帮我,伙计们!
更新了代码
<?php
$host = 'localhost';
$user = 'root';
$pass = ' ';
$dbname = 'itravel';
//date_default_timezone_set('Asia/Kuala_Lumpur');
//$date = date('Y_m_d');
$backup_name = 'itravel_backup.sql';
if(isset($_POST['backup']))
{
$backup = "c:/xampp/mysql/bin/mysqldump --opt -h $host -u $user $dbname > $backup_name";
system($backup);
}
if(isset($_POST['restore']))
{
//$restore = "c:/xampp/mysql/bin/mysqldump --opt -h $host -u $user $dbname < itravel_backup_$date.sql";
//system($restore);
$restore = "c:/xampp/mysql/bin/mysql --opt -h $host -u $user $dbname < $backup_name";
system($restore);
}
?>
但仍然无法正常工作