Home >Database >Mysql Tutorial >Mysql 导入导出csv 中文乱码问题的解决方法_MySQL

Mysql 导入导出csv 中文乱码问题的解决方法_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-01 13:25:31867browse

bitsCN.com

导入csv:

load data infile '/test.csv' into table table_name
fields terminated by ','  optionally
enclosed by '"' escaped by '"'
lines terminated by '/r/n'
ignore 1 lines;

导csv:

SELECT * INTO OUTFILE '/test.csv' 
FIELDS TERMINATED BY ',' OPTIONALLY
ENCLOSED BY '"'
LINES TERMINATED BY '/n'
FROM table_name;

解决导出csv中文乱码问题:

将csv用txt打开,另存为,选择utf8编码即可。

解决导入问题:

mysql安装目录下的my.ini,增加如下参数:

[client]
default-character-set=utf8

[mysqld]
default-storage-engine=INNODB
character-set-server=utf8
collation-server=utf8_general_ci

重启mysql服务。

bitsCN.com
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