Reputation: 456
Im trying to use mysqldump like below:
mysqldump -hlocalhost -uadmin -padmin shop> D:\b2\shop3.sql
When i execute it in command prompt, the file shop3 is generated with all the tables from the shop database. But, when I use it in my php file like below, it generates an empty file.
$cmd = 'mysqldump -hlocalhost -uadmin -padmin shop > D:\b2\shop3.sql';
system($cmd);
Can anyone help me find my error please? Thanks
Upvotes: 1
Views: 2048
Reputation: 360572
mysqldump may not be in the path, so try putting in an absolute C:\....\mysqldump
in there. As well, add in a $return_val var to the call, so you can retrieve the exit value of the command. If mysqldump is failing for whatever reason, it will return a non-zero exit status and you can get that with system($cmd, $return_val)
.
Upvotes: 2
Reputation:
One thing I have noticed on windows when making system calls, you need to point to the .bat file to run the command.
Upvotes: 0