PHP online MySQL Big Data import program

Source: Internet
Author: User
Tags php online phpmyadmin


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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.