How to store Emoji Character in MySQL Database

后端 未结 16 2015
迷失自我
迷失自我 2020-11-22 05:34

I am using Emoji character in my project. That characters are saved (??) into mysql database. I had used database Default collation in utf8mb4_general_ci. It sh

16条回答
  •  广开言路
    2020-11-22 06:19

    The command to modify the column is:

    ALTER TABLE TABLE_NAME MODIFY COLUMN_NAME TYPE;
    

    And we need to use type = BLOB

    Example to modify is as under:-

    ALTER TABLE messages MODIFY content BLOB;
    

    I checked that latest mySQL and other databases don't need '' to use in command on table_name, column_name etc.

    Fetch and Save data: Directly save the chat content to column and to retrieve data, fetch data as byte array (byte[]) from db column and then convert it to string e.g. (Java code)

    new String((byte[]) arr) 
    

提交回复
热议问题