Scheduled backup of MySQL database under Windows.

Source: Internet
Author: User

Note: the "Task Scheduler" that Windows comes with must be seen in this tutorial first.

First, create a bat suffix file. My is Timerexecutephp.bat file

Timerexecutephp.bat This file is used to execute the specified PHP file periodically

Timerexecutephp.bat File Contents:

F:\web\php-5.6.22-Win32-VC11-x64\php.exe F:\web\htdocs\demo\timer.php

Comments:

1. F:\web\php-5.6.22-Win32-VC11-x64\php.exe is the Php.exe file path under the PHP installation directory

2, F:\web\htdocs\demo\timer.php to execute the PHP file

Then is the PHP file to execute such as: timer.php

<?PHP/*regularly back up database files*///Setting the time zoneDate_default_timezone_set (' PRC ' );//generate file names based on time$bakFileName=Date(' Ymdhis ', Time() ) . '. SQL ';$command= "F:/web/mysql-5.6.31-winx64/bin/mysqldump-u Root-pabner Dede >f:/test\\{$bakFileName}";/** * f:/web/mysql-5.6.31-winx64/bin/mysqldump mysql installed directory mysqldump file path * Root Database account * Abner Database Password * Dede to back up the database name * f:/ test\\{$bakFileName} Generate backup File * *-------------------EXEC () function usage------------------------------------* EXEC syntax: string EXEC (String command, string [array], int [return_var]); * Exec return Value: String * command– command to execute * array– is output value * return_var– is the return value 0 or 1, if return 0 succeeds, return 1 execution fails*/exec($command,$arr,$num);if($num= = 0)    Echo"OK";Else    Echo"No";?>

Scheduled backup of MySQL database under Windows.

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.