utf8 to utf8mb4 – directly modify the MySQL database character set

Original link: https://www.zzxworld.com/posts/change-mysql-charset-from-utf8-to-utf8mb4

An old project at hand uses MySQL’s utf8 character set. When encountering a scene where special characters are to be saved (such as Emoji), an error such as “Incorrect string value: ‘\xX0\xXD…'” will be reported. When encountering this problem, either clean up these special contents before saving, or upgrade the character set of the database to utf8mb4.

This article is transferred from: https://www.zzxworld.com/posts/change-mysql-charset-from-utf8-to-utf8mb4
This site is only for collection, and the copyright belongs to the original author.