Pouyan Izadi
Pouyan Izadi

Reputation: 19

mysqldump executes but backup file is empty

I tried to backup a MySQL database with this code:

$user="admin";
$pass="";
$dbname="mobiledb";
$backupFile = 'c:\\onstor.sql';
$command = "mysqldump  -u ".$user." -p".$pass." ".$dbname." > ".$backupFile;
system($command);

The onstor.sql file gets created but its size is 0 bytes!

What's the problem with this?

Upvotes: 1

Views: 5488

Answers (2)

dwjv
dwjv

Reputation: 1227

Try referencing mysqldump absolutely: /usr/bin/mysqldump

Or in Windows it might be something like this: C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqldump

Upvotes: 3

Dennis Leon
Dennis Leon

Reputation: 163

Ensure you have the correct privileges to run mysqldump against your database.

As root run:

    GRANT SELECT, LOCK TABLES ON *.* TO admin@localhost

If still no luck, to help with identifying the root cause of the problem, run your mysqldump command from the command line (not via a script) just incase it is due to some file permission issues during standard output redirection.

Upvotes: 0

Related Questions