The question is i have the table suppose, location_master and the table have colom like ‘postcode’, ‘latitude’, ‘longitude’, ‘county’, ‘region’, ‘town’ and thats all , and i have get or generate the all data about the table in suppose .sql or .csv file format, the fact is when i have the data size above 1 GB then how should i import the large data from that csv or sql file to our mysql database table.
generally all use the import facility which the phpmyadmin provide to us. but thats not full proof that to import all the data from file there can be it stop from the half way and also it takes so much time.
the best way to import the data is to fire the import query like below,
We have to use ‘LOAD DATA INFILE’ query to import the file data,
1) Suppose I have to create one dummy table in my database, like the following,
CREATE TABLE location_master LIKE your_table;
the above query is used to create one dummy table name ‘location_master’ in my db.
2) open your phpmyadmin in your wamp
3) select your database in which you have create table,
4) select your new created dummy table
5) then click on query tab from menubar,
6) write the following query in the textarea of ‘SQL query on database’,
“load data local infile ‘/temp/file.csv’ into table location_master
fields terminated by ‘,’
enclosed by ‘”‘
lines terminated by ‘\n’
(‘postcode’, ‘latitude’, ‘longitude’, ‘county’, ‘region’, ‘town’)”;
fields terminated by ‘,’
enclosed by ‘”‘
lines terminated by ‘\n’
(‘postcode’, ‘latitude’, ‘longitude’, ‘county’, ‘region’, ‘town’)”;
note: please remeber the csv file should contain the same colom which your table have.
7) The above technic is simple and also take very less time to import data.