Mysql 导入导出csv 中文乱码问题的解决方法
程序员文章站
2024-02-24 11:33:22
导入csv:复制代码 代码如下:load data infile '/test.csv' into table table_name fields terminated b...
导入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服务。