0
我試圖讓簡單的PHP腳本來備份databes使用mysqldump,但我得到這個錯誤:PHP:mysqldump的:找不到表「>」
mysqldump: Couldn't find table: ">"
這是,我有寫功能使工作:
protected function dump($params, $dbs, $backup_folder)
{
if (!is_writable($backup_folder)) {
throw new Exception(sprintf('The backup folder is not writable: %s',
$backup_folder));
}
$backup_folder = trim($backup_folder, "/"); // be sure that there is no/at the end
$baseCmd = 'mysqldump --hex-blob --routines --skip-lock-tables -h%s -u%s -p%s %s > %s';
foreach ($dbs as $db) {
$dest = sprintf('%s/%s', $backup_folder,
$db . '_' . date('YmdHis') . '.sql');
$cmd = sprintf($baseCmd, $params['host'], $params['user'],
$params['password'], $db, $dest);
echo "Exec: $cmd: ";
$last = system(escapeshellcmd($cmd), $res);
echo $res;
if (0 !== $res) {
echo "Fail";
} else {
echo "Done \n";
}
}
}
通過此功能給予打印的命令:
mysqldump --hex-blob --routines --skip-lock-tables -hdb-backup -uroot -pMyPwd my_db_name > backups/my_db_name_20151010232734.sql
當我執行從她這個命令它工作得很好,但不是來自PHP腳本。
我的配置是:
- 我的桌面系統外殼:Ubuntu的15.04
- MySQL服務器:安裝在Ubuntu服務器的Mysql 5.6 15.04
- PHP版本:5.6.4
有什麼幫助嗎?
謝謝
謝謝!有用 :) – skonsoft