MySQL Character Sets: Why You Should Always Use utf8mb4

If a MySQL database was created years ago with the plain utf8 charset, it likely can’t actually store emoji or many international characters — a confusing legacy naming decision that still trips people up.

-- Check current charset
SHOW VARIABLES LIKE 'character_set_database';

-- MySQL's "utf8" is actually a 3-byte-max subset, NOT full UTF-8
-- utf8mb4 is the real, complete UTF-8 implementation
ALTER DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE messages CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Why This Matters

The original utf8 charset in MySQL only supports up to 3 bytes per character — enough for most European and Asian scripts, but not enough for emoji or some rarer characters, which need 4 bytes. Inserting an emoji into a plain utf8 column either truncates it or throws an error, depending on strict mode settings.