hibernate - MySQL utf8mb4 unicode (Smiles) -
so, today faced problem:
sql request:
insert `sample` (`lol`) values ('👈');
response:
error code: 1366. incorrect string value: '\xf0\x9f\x91\x88' column 'lol' @ row 1
collation:
mysql> show variables variable_name 'character\_set\_%' or variable_name 'collation%'; +--------------------------+--------------------+ | variable_name | value | +--------------------------+--------------------+ | character_set_client | utf8mb4 | | character_set_connection | utf8mb4 | | character_set_database | utf8mb4 | | character_set_filesystem | binary | | character_set_results | utf8mb4 | | character_set_server | utf8mb4 | | character_set_system | utf8 | | collation_connection | utf8mb4_unicode_ci | | collation_database | utf8mb4_unicode_ci | | collation_server | utf8mb4_unicode_ci | +--------------------------+--------------------+ 10 rows in set, 1 warning (0.00 sec)
my.ini:
[client] port=3306 default-character-set = utf8mb4 [mysql] default-character-set = utf8mb4 [mysqld] character-set-client-handshake = false collation-server = utf8mb4_unicode_ci character-set-server=utf8mb4
how fix it?
the solution simple. need set names 'utf8mb4'
Comments
Post a Comment