简体   繁体   中英

PhpStorm Import data from CSV file to MySQL, Cyrillic problem

I have problem with encoding while trying to import data from CSV file to MySQL database in PhpStorm. The CSV file contains Cyrillic symbols. I've read some articles, tried many things, but none of them worked for me.

In my.ini file I changed:

collation_server=utf8_unicode_ci to collation_server=utf8mb4_unicode_ci and character_set_server=utf8 to character_set_server=utf8mb4

but the result was still the same.

That's my CSV file:

NAME_1,NAME_2,NAME_3
Vladimir,Ivanov,Kaziyski
ИВАН,ПЕТРОВ,ГЕОРГИЕВ
John,Lee,Smith
ПЕТЪР,ЙОРДАНОВ,ПЕТРОВ

In PhpStorm I click right-button on the database which I will import data and then I click:

在此处输入图片说明

then I chose the CSV file

在此处输入图片说明

and in the Data Preview section everything looks normal, encoding is set to UTF-8

在此处输入图片说明

and after that I get this error

在此处输入图片说明

Here is the log:

2:1: Data truncation: Incorrect string value: '\xD0\x98\xD0\x92\xD0\x90...' for column `current_db`.`csv_data`.`NAME_1` at row 2
3:1: Data truncation: Incorrect string value: '\xD0\x98\xD0\x92\xD0\x90...' for column `current_db`.`csv_data`.`NAME_1` at row 1
4:1: Data truncation: Incorrect string value: '\xD0\x98\xD0\x92\xD0\x90...' for column `current_db`.`csv_data`.`NAME_1` at row 2
5:1: Data truncation: Incorrect string value: '\xD0\x9F\xD0\x95\xD0\xA2...' for column `current_db`.`csv_data`.`NAME_1` at row 1

I've searched this error and tried almost all solutions, but nothing worked. The problem for sure is Cyrillic. Does anyone with PhpStorm had the same issue and how to fix it?

utf8 vs utf8mb4 does not matter for Cyrillic, only for Emoji and Chinese.

Please provide SHOW CREATE TABLE . I suspect you did not change the CHARACTER SET for the column(s) that will receive the Cyrillic characters.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM