如何在php中使用mysqldump导出数据库?

时间:2015-03-16 07:17:26

标签: php mysql web

我在这里有一个代码,当我在命令提示符下直接使用它cd C:\wamp......指出bin并使用下面的代码转储时,它可以正常工作:

<?php

DEFINE("HOST","localhost");                         // Host Name
DEFINE("USER","root");                              // Database Username
DEFINE("PASSWORD","");                              // Database Password
DEFINE("DATABASE","db_osgamdrp");                   // Database Name
DEFINE("TIMEZONE","Asia/Manila");                   // Server Timezone
DEFINE("BIN","C:\wamp\bin\mysql\mysql5.6.12\bin")   // MySQLi BIN

$Status = 1;
$Message = "";

$Command = "mysqldump --opt -h " . HOST . " -u " . USER . " -p " . PASSWORD . "" . DATABASE . " > ../../../../../resources/database_backup/" . DATABASE . date("Y-m-d-H-i-s") . ".gz";

if (!exec($Command)) { 
    $Status = 0;
    $Message    = "Something Went Wrong. Please Try Again";
}
?>

这段代码有什么问题?它不起作用。

0 个答案:

没有答案