1. by default, csv files made in windows are in the gbk character set, while mysql sets the default utf8 character set. Therefore, convert the files to the utf8 format. Iconv-fgbk-tutf8tmpfile name .csv-otmpfile name 2.csv 2. use the SQL command to import loaddatainfile #... 1. by default, csv files made in windows are in the gbk character set, while mysql sets the default utf8 character set. Therefore, convert the files to the utf8 format.
Iconv-f GBK-t UTF8/tmp/file name .csv-o/tmp/file name 2.csv
2. use SQL commands to import data
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 ignores 1st rows, and 1st rows are header rows.
(Id, email, passwords, name, address, dept, mobile) this refers to the import in the order of this field, that is, the first column of the csv file into the id field of the table, the second column imports the email field ......
If the csv file is followed by a column, ignore it.