Reputation: 25
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
Reputation: 490
MySQL backup syntax should be as below
mysqldump -u --password= >File.dmp
Upvotes: 0
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