user2004096
user2004096

Reputation: 25

mysqldump generates 0kb sql file

I am working on backup and recovery of mySQL database using mysqldump. My code generates an sql file but its empty. Here's my complete code. Thanks a lot.

<?
   shell_exec("mysqldump -u root -p ilamdb > db/ilamdb.sql");
   echo "Back up complete.";
?>

Upvotes: 2

Views: 2787

Answers (2)

Buzz LIghtyear
Buzz LIghtyear

Reputation: 490

MySQL backup syntax should be as below

mysqldump -u --password= >File.dmp

Upvotes: 0

Alexander M. Turek
Alexander M. Turek

Reputation: 576

You used the option -p which tells mysqldump to ask you for a password – which of course only works in an interactive shell. You will have to specify your password directly:

shell_exec("mysqldump -u root --password=yourpassword ilamdb > db/ilamdb.sql");

If you don't use a password, simply leave out this parameter:

shell_exec("mysqldump -u root ilamdb > db/ilamdb.sql");

Upvotes: 3

Related Questions