0

I have written this piece of code to take my database backup. I am using MySQL as my DB and PHP as a compiler.

<?php
$dbhost   = "localhost";
$dbuser   = "root";
$dbpwd    = "admin";
$dbname   = "mydatabase";
mysql_connect($dbhost, $dbuser, $dbpwd, $dbname) or die('Problem');
$dumpfile = $dbname . "_" . date("Y-m-d_H-i-s") . ".sql";
passthru("/usr/bin/mysqldump --opt --host=$dbhost --user=$dbuser --password=$dbpwd --all-databases > $dumpfile");
echo "$dumpfile "; passthru("tail -1 $dumpfile");
?>

The code get executed but the problem is the downloaded file is of 0KB i.e there is no data in the file.

What is the issue. I have searched a lot on internet but unable to find solution for myself.

1
  • 1
    are you sure the /usr/bin/mysqldump is available on the windows machine? shouldnt it be c:\blah\mysql... ? Commented Jun 18, 2012 at 11:30

2 Answers 2

2

If you are using Windows, place the mysqldump.exe executable in the same location as your backup script. That should work

Sign up to request clarification or add additional context in comments.

Comments

0

Check permission for the directory in which your code is running. It should have write permission.

1 Comment

I have given full privilege to the folder still its not working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.