Home > Database > Mysql Tutorial > body text

Share csv import data to mysql instance

PHP中文网
Release: 2017-06-21 16:03:23
Original
1339 people have browsed it

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!