本文介绍了将UTF-8中的批量CSV数据导入MySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将大约10K行的UTF-8编码数据导入到新的MySQL表中。

I'm trying to import about 10K rows of UTF-8 encoded data into a new MySQL table.

我可以成功地使用 LOAD DATA INFILE 通过MySQL Workbench,但是UTF-8字符被破坏。我测试了数据库否则通过PHP和它接受存储UTF-8字符。问题似乎是 LOAD DATA INFILE ,我已经介绍了几个关于这个的线程。

I can do so successfully with LOAD DATA INFILE via MySQL Workbench but it the UTF-8 characters get mangled. I've tested the database otherwise via PHP and it accepts stores UTF-8 charaters fine. The problem seems to be with LOAD DATA INFILE, and I've come across a few threads about this.

有没有人知道解决方法,或者可能是另一个类似简单的方法导入CSV数据?

Does anyone know a workaround, or possibly another similarly easy method to import CSV data?

谢谢。

RESOLVED:

对于看到此问题并遇到相同问题的其他人,只需在运行。比我想象的更简单)

For others who see this and have the same problem, just add character set as a parameter when running LOAD DATA INFILE. Simpler than I realised :)

推荐答案

根据,您可以在自定义数据库中指定 CHARACTER SET 参数

According to MySQL documentation for LOAD DATA, you can specify a CHARACTER SET parameter in your statement to provide the input file character set.

您是否尝试过提供'utf8'作为输入字符集?

Have you tried providing 'utf8' as the input character set?

这篇关于将UTF-8中的批量CSV数据导入MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 03:30