What is the difference between the InnoDB and MyISAM storage engines?
IntermediateConceptMySQL
Answer
Short answer
InnoDB is MySQL's default engine since 5.5: it supports transactions, row-level locking, foreign keys and crash recovery. MyISAM is the old engine: no transactions, table-level locks, no foreign keys and it can be corrupted by a crash. Today you should use InnoDB for everything.
Comparison
| Feature | InnoDB | MyISAM |
|---|---|---|
| Transactions (ACID) | ✅ | ❌ |
| Locking | Row-level | Whole table |
| Foreign keys | ✅ | ❌ |
| Crash recovery | Automatic (redo log) | Often needs REPAIR TABLE |
Consistent backups with --single-transaction |
✅ | ❌ (needs locks) |
| Supported by RDS/Aurora features | ✅ | Limited |
Check and convert
SELECT table_name, engine FROM information_schema.tables WHERE table_schema = 'shop';
ALTER TABLE legacy_logs ENGINE = InnoDB;
What to say in the interview
"InnoDB is transactional with row-level locking, foreign keys and crash recovery; MyISAM uses table locks and has no transactions. I'd convert any MyISAM tables to InnoDB, also because consistent online backups and replication depend on it."
More on MySQL
How do you set up MySQL and log in to it?BeginnerHow do you create a database, a table and see data in MySQL?BeginnerHow do you create a MySQL user for an application and give it permissions?BeginnerHow do you back up and restore a MySQL database?BeginnerWhat is a relational database?BeginnerWhat is the difference between a database, a table, a row and a column?Beginner