PHP online import mysql Big Data program
<?phpheader ("Content-type:text/html;charset=utf-8"); error_reporting (E_all); set_time_limit (0); $file = '. Test.sql '; $data =file ($file); echo "";//print_r ($data); $data _new=array (); $tmp =array (); foreach ($data as $line) { $line =trim ($line); if (strlen ($line) ==0) { continue; } if (substr ($line, 0,2) = = '--') { continue; } if (substr ($line, 0,2) = = '/* ') { continue; } $tmp []= $line; if (substr ($line,-1) = = '; ') { $query =implode (' ', $tmp); $tmp =array (); $data _new[]= $query; }} $mysqli =new mysqli (' localhost ', ' root ', ' root ', ' test '), if ($mysqli->connect_errno) { exit (' Database connection failed! ');} $mysqli->query ("Set names UTF8"), $error =array (), foreach ($data _new as $sql) { $mysqli->query ($sql); $r = $mysqli->error; if ($r) $error []= $r;} Print_r ($r);/*mysql>alter TABLE tbl2 DISABLE KEYS; Query OK, 0 rows Affected (0.00 sec) Mysql>insert to tbl2 SELECT * from TBL1; Query OK, 2000000 row Affected (36.30 sec) records:2000000 duplicates:0 warnings:0mysql>alter TABLE tbl2 ENABLE KEYS; Query OK, 0 rows affected (44.55 sec) */
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.
Share a method of other netizens, small friends can also refer to the next
The above mentioned is the whole content of this article, I hope you can like.