mysqldump

Discussion in 'PHP' started by gigamike, Oct 7, 2007.

  1. #1
    Guys,

    I hope you can help me, im having truoble executing mysqldump via php script. Im not sure what user right i should have.

    Sample Code:
    $mysql_username="xxx";
    $mysql_password="yyy";
    $mysql_database="zzz";

    $path=$_SERVER['DOCUMENT_ROOT'];
    $backupFile=$path.'/test.sql';
    $command = "mysqldump -u{$mysql_username} -p{$mysql_password} {$mysql_database} > $backupFile";
    system($command);
    exit();

    Thanks in advance :)

    Mike
     
    gigamike, Oct 7, 2007 IP
  2. Lordo

    Lordo Well-Known Member

    Messages:
    2,082
    Likes Received:
    58
    Best Answers:
    0
    Trophy Points:
    190
    #2
    What is the error message?
    And can you try changing the path to a directory that is write-enabled for all?
    And why do you use "system" not shell_exec?
     
    Lordo, Oct 8, 2007 IP
  3. gigamike

    gigamike Active Member

    Messages:
    165
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    Hi,

    Thanks for the help.

    Actually the directory is writable coz i can fopen a file there and it appends.

    No error message when i use system()

    I try shell_exec but an error occur Warning: shell_exec(): Cannot execute using backquotes in Safe Mode . This line was

    $command = "mysqldump -u{$mysql_username} -p{$mysql_password} {$mysql_database} > $backupFile";
    shell_exec($command);

    Thanks,

    Mike:(


     
    gigamike, Oct 8, 2007 IP
  4. tamen

    tamen Peon

    Messages:
    182
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I've used exec to do shell-commands. Don't know what the difference in exec and shell_exec is, though.
     
    tamen, Oct 8, 2007 IP