Mysql characters - Emoji in the database

I use emojis in our project. our database had CHARACTER SET utf8. But emoji are not saved. Error:

1366 Incorrect string value: '\xF0\x9F\x98\x9C\xF0\x9F...' 
+4
source share
1 answer
  • alert database, datatable CHARSET=utf8mb4, column CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci. Before that, make sure mysql has a higher version than 5.5.3, you can use navicat for this

  • change mysql configuration file, in windows it my.ini, in linux itmy.cnf

    [client] default-character-set = utf8mb4
    [mysql] default-character-set = utf8mb4 
    [mysqld] character-set-server = utf8mb4
    collation-server = utf8mb4_general_ci
    
  • delete characterEncoding=utf-8in properties file

  • restart mysql server

+2
source

Source: https://habr.com/ru/post/1654331/


All Articles