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 |
|