Home > Backend Development > PHP Tutorial > php?导出数据库

php?导出数据库

WBOY
Release: 2016-06-20 12:45:48
Original
848 people have browsed it

如何用php代码把数据库导出来??


回复讨论(解决方案)

mysqldump 命令就可以,或者用工具如phpmyadmin 也可以导出。

mysqldump 命令就可以,或者用工具如phpmyadmin 也可以导出。



mysqldump如何导出数据库??

参考网上的不能用<?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);?>
Copy after login

phpmyadmin 可以导出。

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