Interview Prep/Real-World Interview/Data loss and corruption

After migrating a MySQL database to a new server, customer names show up as "José" and "Müller" in the app.

IntermediateTroubleshootingData loss and corruption
Answer

Likely causes → Character set mismatch, usually double encoding. UTF-8 bytes were read as latin1 during the dump or import (or the client connection charset differs from the column charset), then stored again as UTF-8.

Diagnose →

SHOW VARIABLES LIKE 'character_set%';
SHOW CREATE TABLE customers\G
SELECT name, HEX(name) FROM customers WHERE id = 42;   -- C383C2A9 instead of C3A9 means double encoded

Fix → Stop writes to affected tables, re-dump from the old server with the correct charset (mysqldump --default-character-set=utf8mb4), and re-import. For rows already corrupted, convert them back with CONVERT(CAST(CONVERT(name USING latin1) AS BINARY) USING utf8mb4) after testing on a copy.

Prevent → Use utf8mb4 everywhere (server, database, tables, connections), set the charset explicitly in dumps and connection strings, and include non-ASCII sample rows in migration checks.

All Real-World Interview questions Roadmap: Interview readiness

More on Data loss and corruption