About Emoji Support with MySQL

If you want to support all Unicode characters including emojis in MySQL database, you have to use utf8mb4 encoding instead of utf8.

To create a MySQL database with full Unicode support run SQL query:

1
2
3
CREATE DATABASE mydatabase 
CHARACTER SET utf8mb4 
COLLATE utf8mb4_unicode_ci;

But there is a catch. If you use utf8mb4 encoding, the indexed fields can have the maximum length of 191 characters, e.g.:

1
2
class Bookmark(models.Model):
    url = models.UrlField(_("URL"), max_length=191, db_index=True)

Programming Architecture Databases Django 4.2 Django 3.2 Django 2.2 MySQL