MySQL Source command Super Large file Import method summary

Source: Internet
Author: User
Tags dname

Import 1G of data, but in how not to import, with the command line can be easily done. Use the MySQL source command to import larger files.

The code is as follows Copy Code

Mysql>use dbtest;
Mysql>set names UTF8;
Mysql>source D:/www/sql/back.sql;

To import multiple files through the source command, you can create a new Sou.sql file that holds the following command
For example:

The code is as follows Copy Code
SOURCE D:/a1.sql;
SOURCE D:/a2.sql;

When you run


This allows you to import multiple SQL files within a source command.

But this will have a problem, if there are 1100 of such files we write a command must be very troublesome, below I Baidu search to a solution

The code is as follows Copy Code

Create a new All.sql
Vim All.sql
In the inside write:
SOURCE 1.sql
SOURCE 2.sql
......
SOURCE 53.sql
SOURCE 54.sql
And just
Mysql> Source All.sql


Another large file import solution, this is the user with Server Admin permissions


MySQL Source command to import large SQL


Locate the My.ini file in the MySQL installation directory and add the following code:

The code is as follows Copy Code
Interactive_timeout = 120
Wait_timeout = 120
Max_allowed_packet = 32M


Small example
Mytest_emp_dept.sql file, which reads as follows:

The code is as follows Copy Code
CREATE TABLE EMP (eid int PRIMARY KEY auto_increment, ename VARCHAR not NULL, Esex VARCHAR (a), deptid INT not NULL);
CREATE TABLE Dept (deptid INT PRIMARY KEY auto_increment, Dname VARCHAR () not null,daddress VARCHAR (200));
INSERT into EMP (ename,esex,deptid) VALUES (' Chris ', ' m ', 1), (' Edge ', ' m ', 1), (' Kelly ', ' W ', 2), (' Maryse ', ' W ', 2);
INSERT into Dept (dname,daddress) VALUES (' development ', ' Beijing '), (' Accounting ', ' Shanghai ');
SELECT ename,esex,dname,daddress from Emp,dept WHERE emp.deptid=dept.deptid order by ename;

The command line for importing SQL is as follows:

  code is as follows copy code
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.