MySQL Database Interview Master
100+ MySQL interview questions covering InnoDB architecture, B-Tree indexes, EXPLAIN execution plans, ACID transactions, locking, and replication.
Difficulty Filters
Tools & Options
What is MySQL?
MySQL is an open-source Relational Database Management System (RDBMS) that uses Structured Query Language (SQL). It is one of the most popular databases in the world, known for its reliability, ease of use, and performance. It follows a client-server architecture and is a core component of the LAMP (Linux, Apache, MySQL, PHP/Python/Perl) stack.
What are the main features of MySQL?
Primary features of MySQL include:
1. **Relational Database System**: Stores data in tables with rows and columns.
2. **High Performance**: Optimized for fast read and write operations.
3. **Scalability**: Can handle large datasets and high traffic with ease.
4. **ACID Compliance**: Supports transactions via InnoDB engine.
5. **Security**: Multi-layered security with host-based verification and encrypted connections.
What is the difference between MySQL and SQL?
SQL (Structured Query Language) is a standard language used to interact with databases. MySQL is an actual software project (an RDBMS) that implements SQL.
- **SQL**: A language.
- **MySQL**: A database engine that understands that language.
What is the default port for MySQL?
What is a database in MySQL?
What are the common data types in MySQL?
What is the difference between CHAR and VARCHAR?
How do you create a table in MySQL?
What is a Primary Key?
What is a Foreign Key?
What is the difference between DELETE and TRUNCATE?
What is a Unique Constraint?
How do you add a new column to an existing table?
What is the auto_increment attribute?
How do you insert data into a MySQL table?
What is the WHERE clause used for?
What is the LIMIT clause?
How do you sort results in MySQL?
What are Aggregate Functions?
What is the use of the DISTINCT keyword?
What is a NULL value?
How do you update existing data in a table?
How do you delete a database or a table?
What is the LIKE operator?
What is the default storage engine for MySQL?
How do you explain Inner Join in MySQL?
Explain Left Join and Right Join.
What is a Cross Join?
How do you use the GROUP BY clause?
What is the difference between WHERE and HAVING?
What is an Index in MySQL?
What are the different types of Indexes in MySQL?
What is a View in MySQL?
What are Stored Procedures?
What is a Trigger?
What is a Transaction in MySQL?
What are COMMIT and ROLLBACK?
What is the difference between a Function and a Stored Procedure?
How do you check current running queries in MySQL?
What is a Full-Text Search?
What is Query Optimization?
How do you use the EXPLAIN keyword?
What is a Subquery?
What is the difference between UNION and UNION ALL?
What is the COALESCE() function?
What is a Composite Index?
How do you find the second highest salary from a table?
What is Referential Integrity?
What are the ON DELETE CASCADE and ON UPDATE CASCADE options?
What is the difference between NOW() and CURDATE()?
What are the different isolation levels in MySQL?
Explain the ACID properties in MySQL.
What is Deadlock in MySQL and how to handle it?
What is the difference between Optimistic and Pessimistic Locking?
What is a Binary Log (Binlog) in MySQL?
How does MySQL Replication work?
What is the difference between Statement-Based and Row-Based Replication?
What is horizontal and vertical scaling in MySQL?
What is Sharding?
Explain Query Cache in MySQL.
What is a Buffer Pool in InnoDB?
What are Hidden Columns in MySQL 8.0?
What is the difference between MyISAM and InnoDB?
How to perform a backup of a MySQL database?
What is slow query log?
Explain Window Functions in MySQL 8.0.
What are Common Table Expressions (CTEs)?
What is JSON support in MySQL?
Explain the concept of 'Covering Index'.
What is the purpose of the Performance Schema?
What is an 'Upsert' in MySQL?
How to secure a MySQL installation?
What is the difference between a Temporary Table and a Derived Table?
What is 'Ghost Rows' or 'Phantom Read'?
What is adaptive hash index?
How to find duplicate records in a table?
How to delete duplicate records keeping only one?
Write a query to get the nth highest salary.
How to select rows with a date in the last 30 days?
How to find rows where a column contains only numbers?
Scenario: Your production database is slow. What are your first steps?
How to swap values of two columns in a single UPDATE statement?
How to copy data from one table to another?
How to find the length of the longest string in a column?
Scenario: You need to store hierarchical data (like categories/subcategories). How do you design it?
How to get the first 3 characters of a string?
How to combine first_name and last_name into one column?
How to find the number of days between two dates?
Scenario: A user reports they can't login, but the database seems fine. What DB-related things do you check?
How to get the last inserted ID?
How to return a random row from a table?
How to convert a string to uppercase?
How to check the version of MySQL you are using?
Scenario: You want to ensure no two orders are placed for the same product at the exact same millisecond. How?
How to find all tables in a database?
How to rename a table?
How to grant all privileges to a user on a specific database?
How to see the structure of a table?
Scenario: You deleted a row by mistake. How do you get it back?
How to empty a table without deleting it?
Technical Interview Mastery Blueprint
Proven methodologies and frameworks to succeed in technical and architecture rounds.
1. The Engineering STAR Technique
When responding to architectural or situational questions, structure your answer using Situation, Technical Constraint, Action, and Measurable Result. Rather than jumping straight to syntax, articulate the business problem, why certain patterns (e.g. caching, queuing, immutability) were selected over alternatives, and what latency or throughput improvements were achieved.
2. Defending Architectural Trade-Offs
Senior interviewers evaluate how you weigh trade-offs. Always explain why you chose an approach: e.g., memory overhead vs CPU cycle speed, consistency vs availability (CAP theorem), or normalized schemas vs denormalized fast reads. Stating the drawbacks of your own proposal demonstrates maturity and production experience.
3. Clean Code & Edge-Case Proactivity
In live-coding rounds, communicate your thinking aloud before typing. State edge cases explicitly: null or undefined inputs, extreme boundary values, concurrency races, and network timeouts. Writing modular, well-named functions with deterministic unit tests separates junior candidates from staff-level engineers.
4. Antipatterns to Avoid
Avoid reciting memorized definitions without practical context. Never dismiss non-functional requirements such as security (CSRF, injection, token rotation), observability (logging, metrics), and accessibility (ARIA, semantic standards). Always ask clarifying scope questions before writing complex implementations.
Explore Related Tools
Hand-picked utilities and calculators related to this tool.
