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.";
?>
解决方案
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");