1. Use PHP code to loop the data you want to insert into a file
Random string function Getrandchar ($length) {$str = null; $strPol = " Abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz "; $max = strlen ($strPol) -1;for ($i =0; $i < $length; $i + +) {$str. = $strPol [rand (0, $max)];//rand ($min, $max) generates a random integer}return $str between the Min and Max two numbers;} function Get_customers () {$t =mktime (); Set_time_limit (+); $myFile = "E:/insert.sql"; $fhandler =fopen ($myFile, ' WB ') ; if ($fhandler) {$i =0, while ($i <1000000)//1,000,000 {$firstname = $this->getrandchar (5);//put in a class using the FirstName. ' @qq. com '; $password = SHA1 ($firstname); $sql = "$firstname \t$firstname\t$email\t$password"; Note that the field data is separated by \ t $i++; Fwrite ($fhandler, $sql. " \ r \ n "); } echo "Write successful, time-consuming:", mktime ()-$t; }exit;}
2. Run the load data local infile in the MySQL query to read the files written to the data, you can seconds such as the database million data
LOAD DATA local INFILE ' e:/insert.sql ' into TABLE gc_customers (' FirstName ', ' LastName ', ' email ', ' password ');
Seconds speed insert million test data MySQL, provide you to play big data!