MySQL interview questions for hiring: 40 to ask and how to score them
40 MySQL interview questions by level, what strong and weak answers sound like, and how to run a fair MySQL skills test before interviews.

MySQL interview questions work best when they test what the job needs on day one: writing correct queries, reading an execution plan, protecting data in transactions and keeping a production server healthy. Below are 40 questions grouped by level and role, each with what a strong answer covers and the red flag that should make you probe further.
You will also find how to create and administer an effective MySQL test, so the interview only goes to candidates who have already shown they can write SQL.
TL;DR:
- Ask MySQL interview questions that match the role: query and join skills for developers and analysts, execution plans and locking for senior engineers, backup, replication and upgrades for DBAs.
- Screen with a timed MySQL skills test first, then use the live interview to probe how candidates reason about the queries they wrote.
- Score every answer on a 1 to 4 scale written before the interviews start, so two interviewers reach the same verdict.
- Watch for out-of-date answers: the query cache was removed in MySQL 8.0, InnoDB has been the default engine since 5.5, and MySQL 8.0 reached end of life in April 2026.
- Strong candidates explain trade-offs, such as why a composite index helps one query and slows writes, instead of reciting definitions.
- MySQL is used by 40.5% of developers in the 2025 Stack Overflow survey, so most backend hires will touch it.
What should MySQL interview questions test?
MySQL interview questions should test four things: query writing (SELECT, joins, grouping, subqueries), performance (indexes and EXPLAIN), data safety (transactions, locking, constraints) and operations (backups, replication, users and upgrades). How deep you go depends on the role. A data analyst needs the first area done well; a DBA needs all four.
MySQL is still one of the most common databases a new hire will meet. According to the 2025 Stack Overflow Developer Survey, 40.5% of all respondents and 39.6% of professional developers use MySQL, second only to PostgreSQL. That reach is why resumes list it so often, and why a listed skill needs checking.
Skill area | Backend developer | Data analyst | Data engineer | DBA |
|---|---|---|---|---|
SELECT, filtering, grouping | Must have | Must have | Must have | Must have |
Joins, subqueries, CTEs | Must have | Must have | Must have | Must have |
Window functions | Useful | Must have | Must have | Useful |
Indexes and EXPLAIN | Must have | Basic | Must have | Must have |
Transactions and locking | Must have | Rarely needed | Useful | Must have |
Schema design and normalization | Must have | Basic | Must have | Must have |
Users, roles and security | Basic | Rarely needed | Useful | Must have |
Backup, recovery, replication | Rarely needed | Rarely needed | Useful | Must have |
Upgrades (8.0 to 8.4 LTS) | Basic | Rarely needed | Useful | Must have |
For a role-specific starting point, the MySQL developer job description template lists the duties these questions map to, so you can pick the rows of this table that match your opening.

Which basic MySQL interview questions should every candidate answer?
Basic MySQL interview questions check SQL literacy: the commands, keys, data types and NULL rules every candidate uses daily. Ask three or four of these early in a screen. A candidate who misses more than one is unlikely to pass the harder rounds, whatever the resume says.
# | Question | A strong answer covers | Red flag |
|---|---|---|---|
1 | What is the difference between DELETE, TRUNCATE and DROP? | DELETE removes chosen rows and can be rolled back; TRUNCATE empties the table, resets AUTO_INCREMENT and commits at once; DROP removes the table itself | Says all three are the same apart from speed |
2 | How is a PRIMARY KEY different from a UNIQUE key? | One primary key per table, never NULL, and InnoDB stores rows in primary key order; a UNIQUE key allows NULLs and a table can have several | Does not know a primary key cannot be NULL |
3 | When do you use WHERE and when HAVING? | WHERE filters rows before grouping; HAVING filters groups after GROUP BY, usually on an aggregate | Uses HAVING for every filter |
4 | What is the difference between CHAR and VARCHAR? | CHAR is fixed length and padded; VARCHAR stores only the characters used plus a length byte or two | Picks CHAR for free-text fields like names |
5 | Which data type should store money? | DECIMAL with a fixed scale, because FLOAT and DOUBLE round values | Chooses FLOAT |
6 | How do you find rows where a column has no value? | Use IS NULL, because NULL = NULL is not true | Writes WHERE column = NULL |
7 | What is the difference between INNER JOIN and LEFT JOIN? | INNER returns only matches; LEFT keeps every row from the left table and fills NULLs where there is no match | Cannot say which join keeps unmatched rows |
8 | What is the difference between UNION and UNION ALL? | UNION removes duplicates and costs a sort; UNION ALL keeps every row and is faster | Thinks they are interchangeable |
9 | What does AUTO_INCREMENT do and what are its limits? | Generates the next integer key; gaps appear after rollbacks or deletes, so values are not a row count | Uses the max ID as a count of rows |
10 | What is a foreign key and why use one? | A column that must match a key in another table, which stops orphan rows; supported by InnoDB | Says foreign keys only slow things down, with no trade-off |
Which intermediate MySQL interview questions suit developers?
Intermediate MySQL interview questions show whether a developer can write queries that stay correct and fast as data grows. These suit backend developers, full stack developers and data analysts with two or more years of hands-on SQL, and they form the core of any MySQL developer test.
# | Question | A strong answer covers | Red flag |
|---|---|---|---|
11 | Why is InnoDB the default storage engine? | Transactions, row-level locking, crash recovery and foreign keys; default since MySQL 5.5 | Recommends MyISAM for new tables |
12 | How does a composite index work, and does column order matter? | Order matters: the index is used from the leftmost column, so (customer_id, created_at) helps a filter on customer_id but not one on created_at alone | Adds one index per column and expects them to combine |
13 | What is a covering index? | An index that holds every column the query needs, so MySQL never reads the table rows | Has not heard of reading data from the index alone |
14 | Why might WHERE YEAR(created_at) = 2025 ignore an index? | A function on the column stops index use; rewrite as a date range | Blames MySQL instead of the query |
15 | What are the ACID properties? | Atomicity, consistency, isolation, durability, with an example such as a funds transfer | Lists the words but cannot give an example |
16 | What is the default isolation level in InnoDB? | REPEATABLE READ, and what changes under READ COMMITTED | Guesses SERIALIZABLE |
17 | When would you use a CTE instead of a subquery? | CTEs (MySQL 8.0 and later) make multi-step queries readable and can be recursive, for example for a category tree | Does not know MySQL supports CTEs |
18 | How do you return the second highest salary per department? | DENSE_RANK() or ROW_NUMBER() over PARTITION BY department, then filter on the rank | Only knows LIMIT 1 OFFSET 1 for the whole table |
19 | How does MySQL handle a FULL OUTER JOIN? | MySQL has no FULL OUTER JOIN; combine a LEFT JOIN and a RIGHT JOIN with UNION | Writes FULL OUTER JOIN and expects it to run |
20 | Why is SELECT * a problem in application code? | Pulls unused columns, breaks covering indexes and changes results when the schema changes | Sees no issue |
Pro tip: Ask question 14 or 18 as a short written task rather than a spoken question. Candidates who can explain an index rule out loud sometimes still write the slow version under time pressure.
Which advanced MySQL interview questions suit senior engineers?
Advanced MySQL interview questions test judgment on performance, concurrency and schema change in production. Use them for senior backend engineers, data engineers and tech leads, and expect candidates to talk about trade-offs and real incidents rather than definitions.
# | Question | A strong answer covers | Red flag |
|---|---|---|---|
21 | An EXPLAIN shows type ALL and rows 4,200,000. What next? | A full table scan; check the WHERE and JOIN columns, add or fix an index, confirm with EXPLAIN ANALYZE | Suggests adding more memory first |
22 | What do "Using filesort" and "Using temporary" mean in EXPLAIN? | Extra sort or temporary table work, often fixed by an index that matches ORDER BY or GROUP BY | Treats them as errors to ignore |
23 | How does InnoDB handle a deadlock? | Detects it and rolls back one transaction; the app should retry, and access tables in a consistent order | Says deadlocks only happen with bad hardware |
24 | Why is OFFSET pagination slow on large tables, and what replaces it? | MySQL still reads every skipped row; use keyset pagination on an indexed column | Has never seen the problem |
25 | How do you add a column to a large table without downtime? | Online DDL, ALGORITHM=INSTANT where supported, or a tool that copies in the background; test on a replica first | Runs ALTER TABLE on production at peak time |
26 | When would you store data in a JSON column? | Flexible attributes read as a whole; index paths with generated columns; keep relational data relational | Puts everything in JSON to avoid schema design |
27 | What is an invisible index used for? | Testing the effect of dropping an index safely before removing it (MySQL 8.0 and later) | Does not know the feature exists |
28 | What changes when you move from MySQL 8.0 to 8.4 LTS? | Check deprecated features and authentication (mysql_native_password is off by default in 8.4), run the upgrade checker, test on a replica | Has not planned for the 8.0 end of life |
Which MySQL DBA interview questions test operations skills?
MySQL DBA interview questions focus on keeping data safe and the server available: backups, recovery, replication, access control and monitoring. Database administrators and architects earn a median of $126,760 a year, with about 7,300 openings a year on average, according to the US Bureau of Labor Statistics. A wrong hire here is expensive, so test these skills directly.
# | Question | A strong answer covers | Red flag |
|---|---|---|---|
29 | How do you back up a large MySQL database? | Logical dumps (mysqldump or MySQL Shell dump utilities) versus physical backups, schedule, and regular restore tests | Has never tested a restore |
30 | How does point-in-time recovery work? | Restore the last full backup, then replay binary logs up to the moment before the bad change | Only knows full restores |
31 | How does replication work and how do you check lag? | Binary log on the source, replica applies events; GTIDs; SHOW REPLICA STATUS and lag monitoring | Still uses only the old MASTER and SLAVE commands |
32 | How do you give a reporting team read access safely? | A role with SELECT on the needed schemas, a separate user per team, point it at a replica | Shares the root account |
33 | How do you find the slowest queries on a server? | Slow query log with a sensible long_query_time, Performance Schema and the sys schema | Waits for users to complain |
34 | Which server settings would you check first on a new InnoDB server? | innodb_buffer_pool_size sized to memory, redo log capacity, max_connections, with reasons | Changes settings at random |
35 | How would you plan the move off MySQL 8.0 now that it is end of life? | Inventory versions, read the 8.4 LTS changes, upgrade a replica, test the app, then switch over with a rollback plan | Sees no risk in staying on an unsupported version |
For a role-ready screen, the MySQL database administrator test covers these areas before you spend interview time.
Which hands-on MySQL query tasks should candidates complete?
Hands-on MySQL query tasks show how a candidate writes SQL, which a spoken answer cannot. Give every candidate the same small schema: customers (id, name, country), orders (id, customer_id, total, created_at) and order_items (order_id, product_id, quantity, price). Then ask for these five queries, which complete the 40.
- Task 36, recent buyers: List customers from Germany with at least one order over $500 in the last 90 days, newest first.
- Task 37, customers with no orders: Return every customer and their order count, including customers with zero orders.
- Task 38, top three per country: Rank customers by total spend within each country and return the top three, using a window function.
- Task 39, duplicate cleanup: Find and delete duplicate customers with the same name and country, keeping the lowest id.
- Task 40, fix a slow query: Given a query that filters orders on DATE(created_at), explain why it is slow and rewrite it so it can use an index.
Score the output, then the approach: did the candidate use the right join, handle NULLs, and think about indexes? Two candidates can return the same rows while one would scan millions of rows in production.
Which answers show out-of-date MySQL knowledge?
Out-of-date MySQL answers are a quick signal that a candidate learned the database years ago and has not kept up. Many interview question lists online still carry these old answers, so candidates repeat them. MySQL 8.0 reached end of life in April 2026 and 8.4 is the long-term support line, as the Oracle MySQL server versions documentation notes.
- Query cache: A candidate who suggests turning on the query cache is describing a feature removed in MySQL 8.0.
- MyISAM as default: InnoDB has been the default storage engine since MySQL 5.5.
- utf8 for all text: In MySQL, utf8 is a 3-byte alias that cannot store emoji; current versions default to utf8mb4.
- MASTER and SLAVE commands: Replication statements now use SOURCE and REPLICA; the old forms were deprecated in 8.0.
- mysql_native_password everywhere: MySQL 8.4 turns this plugin off by default; caching_sha2_password is the default.
- No window functions: ROW_NUMBER, RANK and CTEs have been in MySQL since 8.0, so "MySQL cannot do that" is no longer true.
Key takeaway: An out-of-date answer is not an automatic rejection. Ask a follow-up such as "What changed in 8.0?" A strong candidate corrects themselves; a weak one has no idea the feature moved on.
How do you create and administer an effective MySQL assessment?
An effective MySQL assessment is short, role-specific and given before the live interview, so interviewers only meet candidates who can already write working SQL. The steps below take a team from job description to a ranked shortlist, and they keep the MySQL assessment fair because every candidate gets the same questions, time and rules.
- Write down the day-one tasks: List the MySQL work the hire will do in the first month, such as writing reporting queries, tuning slow endpoints or running backups. Each task becomes a skill to test.
- Pick the level by role: Use the table in the first section. Developers and analysts need the basic and intermediate questions; senior engineers and DBAs add the advanced and DBA sets.
- Mix question formats: Combine multiple-choice questions for concepts with at least two hands-on query tasks. Concept questions are quick to score; query tasks show real skill.
- Set time and rules up front: 30 to 45 minutes works for a first screen. Tell candidates the topics, the time limit and whether documentation is allowed.
- Fix the pass mark before results arrive: Agree the threshold and the scoring guide first. Setting it after you see scores invites bias.
- Protect integrity: Use proctoring such as tab-switch tracking, copy-paste blocking and webcam snapshots for remote tests, and tell candidates about it in advance.
- Hand the top scorers to a structured interview: Use the advanced questions and the candidate's own test answers as talking points.
Hiring teams need this discipline. The SHRM 2025 Talent Trends report found that 69% of organizations still struggle to fill roles, so a screen that rejects good candidates on badly chosen questions costs time you do not have. For the interview stage, a structured interview keeps the questions and scoring the same for everyone.
How should you score MySQL interview answers?
MySQL interview answers should be scored on a short scale with a written description for each level, agreed before the first interview. A 1 to 4 scale works well because it forces a decision; a middle score of 3 out of 5 lets interviewers avoid one.
Score | What the candidate does | Example for "find the second highest salary per department" |
|---|---|---|
4: Strong | Correct, efficient, explains trade-offs and edge cases | Uses DENSE_RANK over a partition, mentions ties and the index that helps |
3: Good | Correct with minor inefficiency or a missed edge case | Correct query, does not consider ties |
2: Weak | Partly correct or needs heavy hints | Works for one department only |
1: Not shown | Wrong or no answer | Cannot write a grouped query |
Across the teams we work with, the biggest scoring problem is not hard questions. Two interviewers grade the same answer differently because nobody wrote down what "good" means. Keep the scorecard next to the question list, average scores across interviewers and note the evidence behind each score.
How does Testlify help you run a MySQL assessment?
Testlify gives hiring teams a ready MySQL skills test and the tools to run it at scale, so the questions in this guide go to the live interview, not the first screen. The MySQL test is a 30-minute, 25-question intermediate coding assessment that covers areas such as indexing and query optimization, transactions and locking, backup and recovery, and replication.
- Role-ready tests: Combine the MySQL test with others from a library of 3,500+ tests, such as a SQL developer or backend developer test, in one assessment.
- Hands-on coding: Candidates write and run code in coding tests that are graded automatically.
- AI test builder: Generate a custom assessment from your job description, then edit the questions.
- Integrity: 20+ proctoring checks, including tab tracking, copy-paste blocking and webcam snapshots, all described on the anti-cheating and proctoring page.
- Ranked results: Automated scoring and per-skill reports give you a ranked shortlist, and results sync to 100+ ATS and HRIS tools.
For the full hiring process, see the SQL developer hiring guide, and for general SQL roles, the SQL developer interview questions.
Ready to screen MySQL candidates on real skill?
Send the MySQL test before your next round of interviews and spend interview time only on candidates who can already write the queries your team needs. Browse the Testlify test library and start a 7-day free trial with no credit card, or book a demo to see a MySQL assessment built for your role.
Frequently asked questions
B2B SaaS Content Writer
Rishav Kumar is a B2B SaaS content writer with 4 years of experience. He loves crafting engaging content. Always exploring fresh ideas, he's passionate about helping businesses grow through impactful writing.
LinkedInRelated resources
View all
Interview questions
7 interview questions to check if the candidate is tech-savvy

Interview questions
60 HRIS Analyst interview questions to ask job applicants

Interview questions
Employee Relations Specialist Interview Questions: 60 to Ask (2026)

Interview questions
40 compensation specialist interview questions to ask job applicants

Interview questions
60 Warehouse Operator interview questions to ask job applicants

Interview questions
60 Maintenance Coordinator interview questions to ask job applicants
Get started.
Hire on proof, not resumes.
Run your first skills-based assessment free — no credit card required.