0

I am using MySql along with Django. I am trying to save an object containing an emoji. I have changed the charset for the table using the following commands

ALTER DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE mydb.mytable CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

and when I use the command

SHOW FULL COLUMNS FROM table_name;

for seeing the columns I get the following output -

Field: unit_text
      Type: longtext
 Collation: utf8mb4_unicode_ci
      Null: YES
       Key: 
   Default: NULL
     Extra: 
Privileges: select,insert,update,references
   Comment: 

Here coalition is utf8mb4_unicode_ci but still, when I try to save the object I get this error -

OperationalError "Incorrect string value"

Please let me know what I should do

Shahrukh Mohammad
  • 985
  • 2
  • 17
  • 33
  • Possible duplicate of [How to store Emoji Character in My SQL Database](https://stackoverflow.com/questions/39463134/how-to-store-emoji-character-in-my-sql-database) – dfundako Jul 30 '18 at 16:47
  • You know that collation character set only plays a role when ordering result sets or comparing values like with < or >, right? You need to set the character set on your session (connection). Try issuing `SET NAMES 'utf8'` once the connection is established. – marekful Jul 30 '18 at 16:52
  • i used set names, it didn't work, please let me know what else I can try – Shahrukh Mohammad Jul 30 '18 at 16:57

0 Answers0