I'm allowed to use mysqldump, but not using the shell. So I need a PHP script to run mysqldump command

I tried these (I did a search in the forum and found them), but with NO success...:

<?php
 $command = "/usr/bin/mysqldump --opt --host=sql.xxx.it --user=xxx --password=xxx databasename > backup.sql";
passthru($command,$error);
if ($error) {
  echo "Error: ". $error;
} 
?>
<?php
$server  = "sql.xxx.it";
$user = "xxx";
$pass = "xxx";
$connect = mysql_connect($server,$user,$pass);

$getdump = mysql_query("/usr/bin/mysqldump --opt databasename > backup.sql", $connect);
?>

    I finally made it:
    $create_backup = exec("/usr/bin/mysqldump --opt --host=sql.server.it --user=username--password=psw databasename > /home/htdocs/temp/backup.sql");

    And I gave a chmod 777 to temp directory... and then just download the file...

      Write a Reply...