Window automatic task implementation database scheduled backup

Source: Internet
Author: User

Principle: Use window Timer task timed cmd load Mytask.bat file, bat run Php.exe program compile run mytask.php file

, which enables the database to be backed up

Mytask.bat

Content:

D:\phpStudy\php53\php.exe D:\www\mytask.php

mytask.php

Content:

$filename =date (' Ymdhis ', Time ());

$command = "D:\phpStudy\MySQL\bin\mysqldump-u root-proot-d sx > d:\dbbak\\{$filename}.sql";
EXEC ($command);

Window Control Panel (test Win8)-Administrative Tools-Task Scheduler-actions-Create task-set general name-New trigger-new action

Several common methods of mysqldump:

(1) Export the entire database (including data in the database)

Mysqldump-u username-p dbname > Dbname.sql

(2) Export database structure (without data)

Mysqldump-u username-p-D dbname > Dbname.sql

(3) Export a data table (containing data) in the database

Mysqldump-u username-p dbname tablename > Tablename.sql

(4) The table structure of a data table in the export database (without data)

Mysqldump-u Username-p-D dbname tablename > Tablename.sql

Window automatic task implementation database scheduled backup

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.