<?php $t=mktime(); set_time_limit(100000000000); $myFile="D:/insert.sql"; $fhandler=fopen($myFile,'wb'); if($fhandler){ $i=0; while($i<25000000)//1,000,000 { $sql = rand(1,10)." this is my title".$i." this is my content".$i." ".rand(0,2)." ".rand(0,2)." ".rand(0,2)." ".rand(0,2)." ".time(); $i++; fwrite($fhandler,$sql." "); unset($sql); } echo"写入成功,耗时:",mktime()-$t; }
完成后执行,在对应的数据库中执行
LOAD DATA local INFILE 'd:/insert.sql' INTO TABLE content(`typeid`, `title`,`content`,`ifphoto`,`ifattr`,`sort`,`status`,`create_time`);