windows下mysql資料庫定時備份。

來源:互聯網
上載者:User

標籤:5.6   int   time   教程   file   資料庫檔案   注釋   mysql安裝   root   

注意:看本教程先必須會windows內建的“工作排程器”。

 

首先建立一個bat尾碼的檔案我的是timerExecutePhp.bat檔案

 

timerExecutePhp.bat 這個檔案是用來定時執行指定的php檔案

timerExecutePhp.bat檔案內容:

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

注釋:

1、F:\web\php-5.6.22-Win32-VC11-x64\php.exe  是php安裝目錄下的php.exe 檔路徑

2、F:\web\htdocs\demo\timer.php 要執行的php檔案

 

 

 

 

然後就是要執行的php檔案如:timer.php

<?php/*定時備份資料庫檔案*///設定時區date_default_timezone_set( ‘PRC‘ );//根據時間組建檔案名稱$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安裝的目錄mysqldump檔案的路徑 * root 資料庫帳號 * Abner 資料庫密碼 * dede 要備份資料庫名稱 * F:/test\\{$bakFileName} 產生備份的檔案 *  * -------------------exec()函數用法------------------------------------ * exec文法: string exec(string command, string [array], int [return_var]); * exec傳回值: 字串 * Command – 需要執行的命令 * Array –  是輸出值 * return_var –是傳回值0或1,如果返回0則執行成功,返回1則執行失敗 */exec($command,$arr, $num);if($num == 0)    echo "ok";else    echo "no";?>

 

windows下mysql資料庫定時備份。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.