mysqllaravelmysql-cli

mysqldump sql file save without content


i have this php script.when i run the script mysqldump, The file got saved but the content is empty. Any help is appreciated.

thank you.

$filename = "backup-" .  date("YmdHis") .  ".sql";
$pathfile = public_path('database') .'/' .$filename;

exec('mysqldump -u'.env('DB_USERNAME').' -p'.env('DB_PASSWORD').' '.env('DB_DATABASE'). ' > ' . $pathfile);

echo 'done';

No Error is printing, But the file is empty


Solution

  • You need to make sure that the mysqldump processor is in a folder that is on your PATH or you have to add the complete path to the mysqldump processor to the PHP call to the processor.