The csv table contains Chinese characters. Specific implementation code example:
load data infile 'C:\\Users\\Administrator\\Desktop\\import\\CELLutf.csv' into table cell character set gbk (set gbk character encoding to prevent Chinese garbled characters)
fields terminated by ','
enclosed by '"'
lines terminated by '\r\n'
IGNORE 1 LINES;
Code explanation:
fields terminated by ',': The delimiter between data in the csv file. The csv file is separated by commas by default;
enclosed by '': indicates the envelope character;
lines terminated by '': refers to the line terminator;
IGNORE 1 LINES: Ignore the csv header.
The above is the detailed content of Share csv import data to mysql instance. For more information, please follow other related articles on the PHP Chinese website!