Cannot convert character — charset mismatch
ER_CANNOT_CONVERT_CHARACTER (4009) is returned when MariaDB cannot convert a character from one character set to another during a query — for example, inserting a utf8mb4 emoji into a column defined as latin1.
INSERT INTO t (name) VALUES (_utf8mb4 'ð'); -- Column defined as latin1 cannot represent this character
expected output
ERROR 4009 (HY000): Cannot convert character 0xF09F9880 from utf8mb4 to latin1
Fix 1
Convert the column or table to utf8mb4
WHEN When the column needs to support multi-byte Unicode characters including emoji.
ALTER TABLE t CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Why this works
utf8mb4 is a superset of utf8mb3 and supports the full Unicode range including emoji (U+10000 and above).
Fix 2
Set the connection and database charset
WHEN When the entire database should use utf8mb4.
-- In my.cnf: [mysqld] character-set-server = utf8mb4 collation-server = utf8mb4_unicode_ci -- Per connection: SET NAMES utf8mb4;
Why this works
Setting character-set-server ensures all new tables default to utf8mb4.
✕ Silently strip non-convertible characters
Silent data loss corrupts multi-language content and emoji; surface the error and fix the schema instead.
MariaDB Error Code Reference
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev