MuSQL以文件形式导入导出整个数据库
程序员文章站
2022-05-13 11:55:04
...
MuSQL以文件形式导入导出整个数据库 :lt;?php /* 导出 SELECT * INTO OUTFILE
MuSQL以文件形式导入导出整个数据库 :';
}else{
echo 'Not insert into table '.$row[0].'
';
}
}
echo "The task is finished";
}else{
if (is_writable(DIR)) {
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
$fileName=DIR.$row[0].".txt";
if(file_exists($fileName)){
unlink($fileName);
}
$querySql = "SELECT * INTO OUTFILE '".$fileName."'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\''
LINES TERMINATED BY '\n'
FROM `".$row[0]."`";
mysql_query($querySql) or
die("Could not dump table: ". $querySql . mysql_error());
echo 'dump table '.$row[0].' success.
';
}
echo "The task is finished";
}else{
echo 'Folder '.DIR.' can not writeable';
}
}
mysql_free_result($result);
mysql_close();
?>