使用php生成sql文件,然后再倒入mysql。
1.编写php代码
<?php set_time_limit(0); ini_set("memory_limit", "256M"); $pre = "INSERT INTO `article` (`cid`, `name`, `post`) VALUES "; $sql = $pre; $content=‘‘; for($i=1; $i<10000000; $i++){ $cid = rand(1,100); $k = mt_rand(5,50); for($j=3; $j<=$k; $j++){ $name .= chr(mt_rand(33, 126)); } $s = mt_rand(10,100); for($q=10; $q<=$s; $q++){ $post .= chr(mt_rand(33, 126)); } $name = mysql_real_escape_string($name); $post = mysql_real_escape_string($post); $sql .= "($cid, ‘$name‘, ‘$post‘)"; if($i>0 && $i%1000==0){ file_put_contents(‘D:/web/article.sql‘, $sql.‘;‘, FILE_APPEND); $sql = $pre; }else{ $sql.=‘, ‘; } unset($name, $post); }
2.登陆mysql导入sql文件
source d:/web/article.sql
时间: 2024-11-16 20:18:30