Home » technology »

How to: Use PHP script to generate MySQL Dump

Submitted by Vidhu on Jun 06 2015 Views: 2166 | Subscribe


Here "mysqldump" is an external command so you need to use the "exec()" function to execute this external command .

Please find this example.

$db="maindb";
$user="backupuser";
$pw="urpass1234";
$host="localhost";
echo "Starting MySQL dump";

exec('mysqldump --user='.$user.' --password='.$pw.' --host='.$host.' '.$db.' > db.sql');
echo "Dump Completed";

?>


Tags: PHP,MySQL, mysqldump, php-script

Get email updates. Virus Removal Tips, News, How to, Threat Alerts.

Leave a comment!