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

Source: Internet
Author: User
PHP uses the mysqldump command to export the database, phpmysqldump. PHP uses the mysqldump command to export the database. phpmysqldumpPHP uses external commands to export the database. the code is very simple, so there is no need to talk about it. the php $ dumpFileName directory must have the write permission $ DbH PHP uses the mysqldump command to export

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.

Export PHP uses external commands to export the database. the code is very simple, so there is little talk about it. php // $ dumpFileName directory must have the write permission $ DbH...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.