What is MySQL, what is InnoDB, and how is MySQL different from PostgreSQL?
MySQL is the most widely deployed open-source relational database, owned by Oracle, with the MariaDB fork and Percona Server as close relatives. It powers many web stacks and is available as Cloud SQL for MySQL, Amazon RDS and Aurora MySQL, Azure Database for MySQL and PlanetScale (Vitess).
InnoDB
The default storage engine since MySQL 5.5. It provides ACID transactions, row-level locking, MVCC, foreign keys and crash recovery (redo log, doublewrite buffer). Tables are clustered by the primary key: the data rows live in the primary-key B-tree, and secondary indexes store the primary key as their pointer. MyISAM (no transactions) is legacy.
Versions
MySQL now has LTS releases (8.4 LTS) and short-lived Innovation releases (9.x). 5.7 and 8.0 have reached end of life, so upgrades to 8.4 are common interview context.
Compared with PostgreSQL
- Default isolation Repeatable Read (PostgreSQL: Read Committed).
- Clustered primary keys (PostgreSQL uses heap tables).
- Replication via the binary log with GTIDs; huge ecosystem for sharding (Vitess) and online schema change (gh-ost, pt-online-schema-change).
- Fewer advanced types (JSON yes, but no arrays, ranges or exclusion constraints); CTEs and window functions only since 8.0.
- No transactional DDL: a failed migration can leave partial changes.
Example
CREATE TABLE users (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
email VARCHAR(255) NOT NULL,
name VARCHAR(100) NOT NULL,
profile JSON NULL,
created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
PRIMARY KEY (id),
UNIQUE KEY uq_users_email (email)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- Upsert
INSERT INTO users (email, name) VALUES ('asha@example.com', 'Asha')
ON DUPLICATE KEY UPDATE name = VALUES(name);Follow-up questions interviewers ask
Try answering each one before you open it.
Why use utf8mb4 instead of utf8?
MySQL's old utf8 (utf8mb3) stores at most 3 bytes per character, so emoji and some CJK characters fail to insert. utf8mb4 is real UTF-8 and the default since MySQL 8.0. Watch index length limits when converting long VARCHAR columns.