Nasıl tetikler ki birlikte terk alamadım şekilde php script kullanarak başka bir DB mysqldump yapabilirim?
Böyle bir şey çalışması gerekir:
$db_name = "db";
$outputfile = "/somewhere";
$new_db_name = 'newdb';
$cmd = 'mysqldump --skip-triggers %s > %s 2>&1';
$cmd = sprintf($cmd, escapeshellarg($db_name), escapeshellcmd($output_file));
exec($cmd, $output, $ret);
if ($ret !=0 ) {
//log error message in $output
}
Sonra almak için:
$cmd = 'mysql --database=%s < %s 2>&1';
$cmd = sprintf($cmd, escapeshellarg($new_db_name), escapeshellcmd($output_file));
exec($cmd, $output, $ret);
//etc.
unlink($outputfile);
Yeni veritabanı ilk yaratılan gerekir unutmayın. Ayrıca muhtemelen her komut için bir kullanıcı adı ve parola belirtmeniz gerekir.
edit
Ayrıca tek bir komutta bu yapabilirdi mesela
exec('mysqldump --skip-triggers sourcedb | mysql --database targetdb 2>&1', $output, $return);