Reputation: 25
I am working with myqldump that generates a zero-length file. I tried it many times, but it seems that that it only outputs a zero-length file. I don't know why. Do I need to install something or what ?
<?
shell_exec("mysqldump -hlocalhost -uroot -p -A> db/ilamdb.sql ");
echo "complete";
?>
Upvotes: 1
Views: 286
Reputation: 92845
-p
means ask user for password interactively. Escape or put the password in quotes if it contains one of the following characters * ? [ < > & ; ! | $
--no-defaults
option. You might not need this in your case.2>&1
at the end of the command. That way you'll get the error message for debugging purposes in your file instead of just empty file if an error occurs.Therefore your code to invoke mysqldump
might look like this
$pwd = '*******';
$cmd = "/usr/local/mysql/bin/mysqldump -hlocalhost -uroot -p'$pwd' -A> db/ilamdb.sql 2>&1";
shell_exec($cmd);
Upvotes: 1