Getting 0KB of size file while backup mysql database using mysql dump I am using below code to backup my database using php script but I am getting 0KB size file. How can I backup my full database with all routines and functions?   

$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$dbname='mydatabase';
$toDay = date('d-m-Y');
    //exec("mysqldump --user=$dbuser --password='$dbpass' --host=$dbhost --single-transaction $dbname &gt; D:\Sql_Backups/".$toDay."_DB.sql");
    //exec('mysqldump --user=$dbuser --password=$dbpass --host=$dbhost $dbname &gt; D:\Sql_Backup/file.sql');
      exec ("mysqldump --routines --h $dbhost --u $dbuser --p $dbpass --single-transaction $dbname &gt; D:\Sql_Backup/db3_backup.sql" &gt;
I don't know how to write this in php, but you should write mysqldump command like below, there is no need to write three command one is enough

mysqldump --user=root --password=root --host=localhost --single-transaction --routines db_name &gt; db_name.sql




UPDATE

I did it here is the php script

&lt;?php
define("BACKUP_PATH", "/home/abdul/");

$server_name   = "localhost";
$username      = "root";
$password      = "root";
$database_name = "world_copy";
$date_string   = date("Ymd");

$cmd = "mysqldump --routines -h {$server_name} -u {$username} -p{$password} {$database_name} &gt; " . BACKUP_PATH . "{$date_string}_{$database_name}.sql";

exec($cmd);
?&gt;


It generate backup file named as 20140225_world_copy.sql in /home/abdul/

For reference have a look at This link.