0

I'm using MySQL 5.7.20. My schema, tables and columns are all supporting utf8mb4. I used the following:

ALTER SCHEMA `MyDB`  DEFAULT CHARACTER SET utf8mb4  DEFAULT COLLATE utf8mb4_general_ci ;
ALTER TABLE MyDB.Videos CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

I don't understand why I'm still getting the following error:

DatabaseError: 1366 (HY000): Incorrect string value: '\xF0\x9F\x92\x96' for column 'Content' at row 1

I can't figure out the reason, please help.

3
  • Use proper SET NAMES on the client side.
    – Akina
    Jul 31, 2018 at 8:08
  • Thanks, I only had to specify CHARSET='UTF8MB4' in my connection parameters. Aug 1, 2018 at 19:58
  • Specifying on the connection (where practical) is preferred over SET NAMES.
    – Rick James
    Aug 18, 2018 at 22:02

2 Answers 2

1

When I specified CHARSET='UTF8MB4'in my connection parameters, it worked.

0

Set is working

cursor.execute("SET NAMES 'UTF8MB4'")
cursor.execute("SET CHARACTER SET UTF8MB4")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.