php exec() - mysqldump creates an empty file

后端 未结 7 1655
再見小時候
再見小時候 2021-01-11 14:22

I want to create a backup from a database, but I get only a blank file.

include(\'config.php\');

$command = \"mysqldump --opt -h \".$_host.\" -u \".$_user.\         


        
7条回答
  •  太阳男子
    2021-01-11 14:59

    Take the variables out of the quotes and remove --opt.

    Also make sure that you are having unique file names

    $backupfile = $dbname . date("Y-m-d-H-i-s") . '.sql';

    $command = "D:\xampp\mysql\bin\mysqldump -u $_user -p$_pass $_db > $backupfile";

    system($command);

提交回复
热议问题