Last active
January 7, 2016 07:08
-
-
Save ashokmhrj/ffef27654bd606e393b6 to your computer and use it in GitHub Desktop.
PHP Importing database via CLI mode
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 | |
/** | |
* import db via Command Line Interface (CLI) PHP | |
*/ | |
define('DBUSER','DBUSER'); | |
define('DBPASSWD','DBPASSWRD'); | |
define('DATABASE','DBNAME'); | |
define('HOST','host'); | |
$filename = "backup-" . date("d-m-Y") . ".sql.gz"; | |
$mime = "application/x-gzip"; | |
header("Content-Type: " . $mime); | |
header('Content-Disposition: attachment; filename="' . $filename . '"'); | |
$cmd = "mysqldump -h " . HOST . " -u " . DBUSER . " --password=" . DBPASSWD . " " . DATABASE . " | gzip --best"; | |
passthru($cmd); | |
exit(0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment