Mysql: import from Excel

Published by

Posted on April 30, 2011

You will need to convert you Excel worksheet to a csv file by saving it as .csv

If you have mysql installed locally on your pc , you can run the following query to import your data . *please note you should remove the first column which includes the columns titles. *

LOAD DATA local INFILE ‘C:\\wamp\\file.csv’ INTO TABLE bizdir.directoryFIELDS TERMINATED BY ‘,’ LINES TERMINATED BY ‘\r\n’ (col1,col2);

You will need to make some minor adjustments to the query above including the file name and location. Also the columns name to match the columns in the table you are importing into.  You can then export the data from your local mysql instance to a remote server.