简体   繁体   中英

MySQL Dump file is empty

I try to create backup of my database, it creates file.sql , but it is empty , how can I solve it ?

$backup_file = $filename .'_'. date("Y-m-d-H-i-s") . '.sql';

$command = "mysqldump --opt -h $HostName -u $HostUser -p $HostPass --all-databases". "$DatabaseName > $backup_file";

system($command);

there is no space after --all-databases

$backup_file = $filename .'_'. date("Y-m-d-H-i-s") . '.sql';

$command = "mysqldump --opt -h $HostName -u $HostUser -p $HostPass --all-databases ". "$DatabaseName > $backup_file";

system($command);

the first problem you got o told you in the comment --all_databases' already adds all databases, so no need for adding more databases

The second is you have a space between -p and your password, so mysqldump things it is a database, removing the space will solve that problem.

If you have functions or procedures you need to add more parameters like -routines

--Opt isn't need as it is enabled by default

$backup_file = $filename .'_'. date("Y-m-d-H-i-s") . '.sql';

$command = "mysqldump -h $HostName -u $HostUser -p$HostPass -routines --all-databases > $backup_file";

system($command);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM