Importing bulk CSV data in UTF-8 into MySQL

走远了吗. 提交于 2019-12-21 09:27:38

问题


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

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.

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

Thank you.

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 :)


回答1:


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

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



来源:https://stackoverflow.com/questions/2133198/importing-bulk-csv-data-in-utf-8-into-mysql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!