Use System Function to execute a mysqldump
Posted on 2008-10-30
I am trying to create a mysqldump in PHP:
$command = "mysqldump -h localhost --user=me --password=mypass --no-create-info --opt --where=\"Id<12\" MyDatabase MyTable |sed -e \"s|INSERT INTO|REPLACE INTO|\" > ".$path."replacedump.sql";
The dump file is not being executed.
I can take the string for $command and put in straight to the command line and it works. Then I thought maybe it was the system() function, so I create system("ls",$error); in PHP and it worked, I got the file list in my browser.
Is there a reason why system() is not working with mysqldump. I should have permission to run it because I can do it on the command line. Does PHP read permissions differently? Or is there something wrong with my mysqldump?
I appreciate any help!