Bug #11724 mysql_dump don't run from PHP
Submitted: 4 Jul 2005 14:32 Modified: 4 Jul 2005 18:43
Reporter: [ name withheld ] Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:4.1.7 OS:Windows (Windows XP SP2)
Assigned to: CPU Architecture:Any

[4 Jul 2005 14:32] [ name withheld ]
Description:
Hi,

I just was trying to make run this script that should generate a XML file making use of MYSQLDUMP but on my system the script dosentwork and on other system it works with out any problem. I hear about other problems with this command http://bugs.mysql.com/bug.php?id=1530 and I hope is not a bug just my system but i friend get a XML file with nothing inside like on the bug report.

Thank you on advance for any comment or solution.

How to repeat:
1) Download WAMP server www.wampserver.com
2) put the script and run.

Here the script and it was run under the last copy of WAMP server.
<?php 
class mysql_dump 
{ 
    var $cmd = ''; 

    function mysql_dump($user, $pass, $name, $path) 
    { 
        $this->cmd = "mysqldump -q -X -u {$user} -p{$pass} {$name} -r {$path}{$name}.xml"; 
    } 
    function backup() 
    { 
        passthru($this->cmd, $retval); 

        if(!empty($retval)) 
        { 
            print_r($retval); 
        } 
    } 
} 
// initilize mysqldump 
$dump = new mysql_dump('root', '', 'test', './'); 
// backup database 
$dump->backup(); 
?>
[4 Jul 2005 18:42] Jorge del Conde
I was unable to reproduce this bug.

Using your script, I received the following:
jorge-jorge/tt> php t.php 
mysqldump: option '-r' requires an argument
sh: line 2: ./test.xml: Permission denied
126 

I then changed the line:
$this->cmd = "mysqldump -q -X -u {$user} -p{$pass} {$name} -r
{$path}{$name}.xml";

to:
$this->cmd = "mysqldump -q -X -u $user -p$pass $name -r $path$name.xml";

and a file called test.xml (that contained the dump) was generated.
[4 Jul 2005 18:43] Jorge del Conde
jorge-jorge/tt> ls
./  ../  t.php
jorge-jorge/tt> php t.php 
Enter password: 
 

jorge-jorge/tt> ls
./  ../  test.xml  t.php
jorge-jorge/tt>