开发者

mysqldump generating an empty file

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


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).


One thing I have noticed on windows when making system calls, you need to point to the .bat file to run the command.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜