Importing bulk CSV data in UTF-8 into MySQL

2019-04-06 17:57发布

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条回答
成全新的幸福
2楼-- · 2019-04-06 19:01

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?

查看更多
登录 后发表回答