Home  >  Article  >  Database  >  Share csv import data to mysql instance

Share csv import data to mysql instance

PHP中文网
PHP中文网Original
2017-06-21 16:03:231396browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn