Jump to content

Problem with mysqldump and PHP


dzogchen

Recommended Posts

I have a rather large database that contains a few large tables and a large number of frequently changing very small tables i need to migrate to another server, and do it quickly so I minimize disrption of our site.

 

mysqldump doesn\'t seem to take wildcards, so i wanted to write a php script to automate the execution of mysqldump. I can generate the table names and then i put them into a string something like:

 

$dumpme = \"mysqldump --user=xxxx --password=xxxxx somedatabase $thistable > $thisdump n\";

 

and then use

 

$file = exec(\"$dumpme\");

 

if (!$file) {

echo \"Unable to dump file $thistable!<br> \";

 

}else{

 

echo \"dump of file $thisdump worked!<br>\";

}

 

if I take the string generated by echo $dumpme; and run it in a terminal window, it works.

 

If I run the php code, it fails.

i have also tried it with :

$file = exec($dumpme);

and it still fails. also shell_exec and passthru

 

Any ideas?

 

I thought of using php for generating a long shell script, and running that from the command line.

 

Any help appreciated

Link to comment
https://forums.phpfreaks.com/topic/1406-problem-with-mysqldump-and-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.