Posted in PHP onApril 14, 2015
PHP使用外部命令导出数据库,代码很简单,就不多废话了
<?php // $dumpFileName目录要有可写权限 $DbHost = 'localhost'; $DbUser = 'root'; $DbPwd = '123456'; $DbName = 'a'; $fileName = $DbName . '_MySQL_data_backup_' . date('YmdHis) . '.sql'; $dumpFileName= "/var/$fileName"; header("Content-Disposition: attachment; filename=" . $fileName); header("Content-type: application/octet-stream"); header("Pragma:no-cache"); header("Expires:0"); echo `mysqldump -h $DbHost -u$DbUser -p$DbPwd $DbName > $dumpFileName`; $hd = fopen($dumpFileName, 'rb'); echo fread($hd, filesize($dumpFileName)); fclose($hd); ?>
以上就是本文所述的全部内容了,希望大家能够喜欢。
PHP使用mysqldump命令导出数据库
- Author -
hebedich声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@