I want to import data in an Excel file into MySQL table. MySQL tools like MySQL Query Browser does not provide such function. There are sharewares on the web which provide this function. Instead, you can use function that already provided by MySQL, easy and quick solution.
First, you need to export the data to csv file. Remove any csv headers from the file. After that, run the following script in MySQL Console:
load data local infile 'uniq.csv' into table tblUniq
fields terminated by ','
enclosed by '"'
lines terminated by '\r\n'
(uniqName, uniqCity, uniqComments)
This script loads the file uniq.csv from the local file directory, and imports to table tblUniq. It tokenized the field by terminator, and enclosed all fields with specified character.
In using this script, you need to take care of the special characters in the fields. When exporting csv, if one of the fields got a comma, this field will be enclosed by ” as well. It will cause conflict with the above script. So, to solve this, put your csv file into a Text editor and do some customization before using the script. For example, use “|” instead of “,” for the terminator, etc.
Reference here
Share and Enjoy:
These icons link to social bookmarking sites where readers can share and discover new web pages.