Last active
March 21, 2019 18:32
-
-
Save lawebfabric/8ba32de131dcacda6d39a20f4c52c45d to your computer and use it in GitHub Desktop.
mysql dump php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
ini_set('display_errors', 1); | |
ini_set('display_startup_errors', 1); | |
error_reporting(E_ALL); | |
$database = 'db'; | |
$user = 'user'; | |
$pass = 'pass'; | |
$host = 'localhost'; | |
$dir = dirname(__FILE__) . '/dump.sql'; | |
echo "<h3>Backing up database to `<code>{$dir}</code>`</h3>"; | |
exec("mysqldump --user={$user} --password={$pass} --host={$host} {$database} --result-file={$dir} 2>&1", $output); | |
var_dump($output); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment