Reputation: 15
I need to run this command in php to get my DB backup automatic.
<?php
$output = exec("C:/xampp/mysql/bin/mysqldump -u root -p > my_db.sql");
?>
need help
Upvotes: 1
Views: 679
Reputation: 5224
The -p
flag requires you to enter a password for the user. Since you are using the default configuration (no password) you should remove the flag.
exec("C:/xampp/mysql/bin/mysqldump -u root > my_db.sql");
with that flag it will just hang waiting for you to pass in the password.
If your user had a password you could do:
$output = exec("C:/xampp/mysql/bin/mysqldump -u root -pMyPassword > my_db.sql");
but this is bad idea because if the script is ever exposed your root password will be known.
Upvotes: 1