PHP uses the mysqldump command to export the database, phpmysqldump
PHP uses external commands to export the database. The code is very simple, so there is not much nonsense.
<? Php // $ dumpFileName directory must have the write permission $ DbHost = 'localhost'; $ DbUser = 'root'; $ DbPwd = '000000'; $ 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);?>
The above is all the content described in this article. I hope you will like it.