MySQL Tutorial with Examples.
MySQL tutorial for web and application backends: queries, indexing, replication, stored procedures and performance optimisation.
Beginner
Start here — no prior experience needed
Intermediate
For developers with core concepts down
Composite Indexes: The Filesort a Single-Column Index Can't Avoid
Filtering by genre and sorting by year: a single-column index still needs a manual sort afterward (2.87ms). A composite index on both columns delivers pre-sorted results — measured 21x faster, and the Sort step vanishes from the plan entirely.
A Missing Join Condition Turns 4,000 Rows Into 8 Million
Forgetting the join condition on an old-style comma join doesn't error — it silently produces a cartesian product, 8,000,000 rows where 4,000 were expected. EXPLAIN's join buffer (hash join) with no ON clause is the tell.
Isolation Levels: The Same Transaction Reading Two Different Values
Under MySQL's default REPEATABLE READ, a transaction reads the same value twice even after another session commits a change in between. Switch to READ COMMITTED and the second read sees the new value — a real, measured non-repeatable read.
A Real Deadlock: Error 1213, and the Lock-Order Fix
Two sessions locking the same two rows in opposite order produce a genuine ERROR 1213 deadlock, not a hang — MySQL detects it and kills one transaction immediately. Locking in a consistent order eliminates it entirely, replaced by an ordinary wait.
Stored Procedures and Triggers: Code That Runs Without Being Asked
A stored procedure enforces a business rule with a real SIGNAL error, and a trigger logs every stock change automatically — even for updates that never call the procedure at all.
Backup and Recovery: What a Restore Actually Gives Back
A real mysqldump, a real DELETE with no WHERE clause, and a real restore — which undoes the mistake but also erases legitimate work done after the backup, exposing exactly what a full logical restore can't do alone.
Advanced
Production-grade patterns for experienced engineers
Also part of MySQL
Taught in other topics. Each link opens the lesson in its home topic.