PHP uses the EXEC function to import and export databases

Source: Internet
Author: User
Tags import database
To export the database code:

EXEC ("mysqldump-h localhost-uroot-ppassword--default-character-set=utf8 dbname>d:/aaa.sql 2>&1", $output , $return _val); exit;

Note: 1) between-H and localhost to have a space (otherwise the output will be reported incorrect password)

2)-U and root,-p and password cannot have spaces between them (if there is a space in the middle of the output is empty)

3)--default-character-set=utf8 (used to set the font format for exported documents)

4) 2>&1 if the command in exec is incorrect, it will be printed in the document after adding 2>&1.

Import Database code:

EXEC ("Mysql-h localhost-uroot-ppassword dbname< d:/ccc.sql"); exit;

The above introduces PHP using the EXEC function import and export database, including the content, I hope the PHP tutorial interested in a friend helpful.

  • 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.