mysql批量导出表(限制100条数据)
<?php
set_time_limit(0);
$con = mysql_connect("host", "user", "pwd");
$dbname = "db";
if ($con) {
if (mysql_select_db($dbname, $con)) {
$sql = "SHOW TABLES WHERE Tables_in_$dbname not LIKE '%0%';";
$ret = mysql_query($sql);
while($row = mysql_fetch_assoc($ret)){
$info1[] = $row["Tables_in_$dbname"];
}
foreach ($info1 as $val) {
$cmd = "mysqldump --default-character-set=latin1 -u user -h host -ppwd $dbname $val --where='1 limit 100' >> $val.sql";
shell_exec($cmd);
}
}
}
mysql_close($con);
?>
编程改变生活
posted on 2017-06-19 14:14 coding-farmer 阅读(1235) 评论(0) 收藏 举报
浙公网安备 33010602011771号