1, Windows do CSV file by default is the GBK character set, and MySQL set the default is the UTF8 character set, so to convert the file to UTF8 format.
Iconv-f gbk-t utf8/tmp/file name. csv-o/tmp/file name 2.csv
2. Import with SQL command
Load data infile '/tmp/mailut2.csv ' into table db1.d fields terminated by ', ' lines terminated by ' \ n ' ignore 1 lines (ID, Email,passwords,name,address,dept,mobile);
Ignore 1 lines is ignoring line 1th, row 1th is the header row
(id,email,passwords,name,address,dept,mobile) Here means import in this field order, that is, the first column of the CSV file is imported into the ID field in the table, the second column imports the email field ...
If there is a column behind the CSV file, it is ignored.
This article from "Zw_chen" blog, reproduced please contact the author!
Use a script to import a CSV file into MySQL