1<?PHP2 Header("Content-type:text/html;charset=utf-8");3 error_reporting(E_all);4 Set_time_limit(0);5 $file= './test.sql ';6 $data=file($file);7 8 Echo"<pre>";9 //Print_r ($data);Ten $data _new=Array(); One $tmp=Array(); A foreach($data as $line) { - - $line=Trim($line); the if(strlen($line) ==0){ - Continue; - } - if(substr($line, 0,2) = = '--'){ + Continue; - } + if(substr($line, 0,2) = = '/* '){ A Continue; at } - $tmp[]=$line; - if(substr($line,-1) = = '; '){ - $query=implode(‘‘,$tmp); - $tmp=Array(); - $data _new[]=$query; in } - to } + - the * $mysqli=NewMysqli (' localhost ', ' root ', ' root ', ' test '); $ if($mysqli-Connect_errno) {Panax Notoginseng Exit(' Database connection failed! ‘); - } the $mysqli->query ("Set Names UTF8"); + A $error=Array(); the foreach($data _new as $sql){ + $mysqli->query ($sql); - $r=$mysqli-error; $ if($r)$error[]=$r; $ } - Print_r($r); - the - /*Wuyi the - mysql>alter TABLE tbl2 DISABLE KEYS; Wu Query OK, 0 rows Affected (0.00 sec) - About Mysql>insert to Tbl2 SELECT * from TBL1; $ Query OK, 2000000 row Affected (36.30 sec) - records:2000000 duplicates:0 warnings:0 - - mysql>alter TABLE tbl2 ENABLE KEYS; A Query OK, 0 rows affected (44.55 sec) + the - */
Applicable: phpMyAdmin The exported SQL file is too large to import into the online phpMyAdmin
Upload the program and the SQL file to the space and delete it when you are done.
PHP online MySQL Big Data import program