PHP uses the mysqldump command to export the database, phpmysqldump_PHP tutorial

WBOY
Release: 2016-07-13 09:57:12
Original
933 people have browsed it

PHP uses the mysqldump command to export the database, phpmysqldump

PHP uses external commands to export the database, the code is very simple, no more nonsense

<&#63;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);  
&#63;>
Copy after login

That’s all the content of this article, I hope you all like it.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/984008.htmlTechArticlePHP uses the mysqldump command to export the database, phpmysqldump PHP uses external commands to export the database, the code is very simple, no more nonsense php // The $dumpFileName directory must have writable permissions $DbH...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template