So I'm using a wrapper to fetch user data from instagram. I want to select the display names for users, and store them in a MYSQL database. I'm having issues inserting some of the display names, dealing with, specifically, an incorrect string value error:
Now, I've dealt with this issue before with accent marks, letters with umlauts, etc. The solution would be to change the collation to utf8_general_ci
under the utf8
charset.
So as you can see, some of the display names I'm pulling have very unique characters that I'm not sure mySQL can recognize at all, i.e.:
แ๐ฐ๐๐๐๐ ๐พ๐๐๐๐๐๐๐๐ยฎ
So I receive:
Error Code: 1366. Incorrect string value: '\xF0\x9D\x99\x87\xF0\x9D...' for column 'dummy' at row 1
Here's my sql code
CREATE TABLE test_table(
id INT AUTO_INCREMENT,
dummy VARCHAR(255),
PRIMARY KEY(id)
);
INSERT INTO test_table (dummy)
VALUES ('แ๐ฐ๐๐๐๐ ๐พ๐๐๐๐๐๐๐๐ยฎ');
Any thoughts on a proper charset + collation pair that can handle characters like this? Not sure where to look for a solution, so I come here to see if anyone dealt with this.
P.S., I've tried utf8mb4
charset with utf8mb4_unicode_ci
and utf8mb4_bin
collations as well.
select character_set_name from information_schema.columns where table_name='test_table' and column_name='dummy';
โ DinghyALTER TABLE test_table CONVERT TO CHARSET utf8mb4
to change existing columns. After I did that, I was able to insert your example string to the table in my test. โ DinghyALTER TABLE
and running will change existing columns. Let me try. โ Reynoso