MySQL Interview Questions and Answers

Last updated on Feb 07, 2024
  • Share
MySQL Interview Questions

MYSQL is one of the most successful and leading pathways toward data administration careers. You will be amazed to know that this database service holds a total of 46.83% share in the relational database market. So to make your career and prepare for interviews in this field would be a good choice. Today we will help with these interviews by providing you with some MYSQL Interview Questions and Answers. MYSQL is one of the most popular database technologies used in the database industry. Popular companies like Microsoft, Amazon, Oracle, and IBM are using this technology on a vast basis to manage and store their data. According to one survey, nowadays more than 90% of organizations are using OSDBMS i.e. Open Source Database Management System. But to handle this database, professionals must know the MYSQL programming language.

Quick Facts About MySQL
What is the latest version of MySQL? 8.0.22 released in 19th October 2020
When was MySQL first released? 23 May 1995
Who developed MySQL? Oracle Corporation.
What language does MySQL use? C and C++ language
About License GNU Public License
Official Website

MySQL Query Interview Questions

Here in this article, we will be listing frequently asked MySQL Interview Questions and Answers with the belief that they will be helpful for you to gain higher marks. Also, to let you know that this article has been written under the guidance of industry professionals and covered all the current competencies.

Q21. What is the default port for MySQL and how it can change?

The default port is 3306. We can change it in /etc/MySQL/my.conf there is a port variable. We can update this port according to our need

Q22. What is the difference between IS NULL & IS NOT NULL?

IS NULL checks to see if the cell is empty but IS NOT NULL checks to see if the cell is not empty.

Example :

SELECT id FROM users WHERE 'user_type' IS NOT NULL;

SELECT id FROM users WHERE 'user_type' NOT IS NULL;

Note: This is very essential MySQL query interview questions.

Q23. What are the drivers in MySQL?

In MySQL, standards-based drivers for JDBC, ODBC, and .Net are provided in order to enable developers in building database applications with their language of choice.

Available Drivers in MySQL:

  • PHP Driver
  • JDBC Driver
  • ODBC Driver
  • PYTHON Driver
  • PERL Driver
  • RUBY Driver
  • CAP11PHP Driver
  • Ado.net5.mxj

JDBC, ODBC, and .Net drivers are necessary for MySQL as they enable the developers for building their database applications.

Q24. Explain the difference between primary key and candidate key in Mysql?
Primary Key Candidate Key
It is a column that uniquely identifies a record. In Mysql, only one candidate key can behave like Primary Key. It can be any column that can qualify as a unique key in the database. In MySQL, there can be multiple candidate keys in one table. Each candidate key can behave like as a primary key.
Q25. What is TRIGGERS and how it can be used in MySQL?

In Mysql, a trigger is a database object that is directly associated with a table. It will be activated when a defined action is executed for the table.

It can be performed when you run one of the following MySQL like INSERT, UPDATE and DELETE occurred in a table. Its activation time can be BEFORE or AFTER.

Types of Triggers in MySQL

  • Before Insert: This is done before inserting data into the table.
  • After Insert: This is after data has been entered into the table.
  • Before update: This is activated prior to the updating of the data in the table.
  • After update: This function is activated upon the updating of the table's data.
  • Before delete: This is done before any data are removed from the table.
  • After delete: This function is activated when the data has been deleted from the table.

What is the purpose of triggers in MySQL?

  • It is easy to set up triggers.
  • Triggers allow us to validate data before it is inserted or updated.
  • Triggers allow us to keep track of records, such as audit trails for tables.
  • Triggers increase the performance of SQL queries as it doesn't need to compile every time the query executes.
  • Triggers can be used to reduce client-side code, which saves time and effort.
  • It allows us to scale our applications across multiple platforms.
  • SQL triggers are an alternative method to verify the integrity of data.
  • Triggers are an alternative method to perform the task.


CREATE TRIGGER trigger_name    
         ON table_name FOR EACH ROW    
        --trigger code    // You can write here your code


delimiter //
delimiter ;

Q26. Is MySQL case-sensitive?

Mysql is not case sensitive. Its case-sensitivity relies on the underlying operating system as OS determines the case sensitivity of tables names and database. In windows, database and table names are not case sensitive but in the case of UNIX, it is case sensitive in nature. Especially on the UNIX host, database accepts the upper case and lower-case table names.

Q27. How would you select all the users whose phone is null MySQL?

SELECT id, name FROM users WHERE phone IS NULL;

Q28. How can you insert data into MySQL?

To insert new records into a table, use the INSERT INTO statement. You can write the INSERT INTO sentence in one of two ways.

  • You will need to specify both column names and values that you wish to insert:
    INSERT INTO table_name (column1, column2, column3, ...) VALUES (value1, value2, value3, ...);
  • You don't need to include the column names in your SQL query if you are adding values to all columns in the table. But, ensure that the order of your values matches the order of the columns in the table. The INSERT INTO syntax is as follows:
    INSERT INTO table_name VALUES (value1, value2, value3, ...);


INSERT INTO Customers (name, email, salary) VALUES ('MySQL Query Interview Questions', '[email protected]', 15000);

Q29. What is cardinality in MySQL?

In MySQL, the time period cardinality refers to the specialty of facts values that can be put into columns. It is a type of property that influences the potential to search, cluster and kind data.

Cardinality can be of two sorts which are as follows
  • Low Cardinality − All values for a column have to be the same.
  • High Cardinality − All values for a column ought to be unique.
Q30. How to store binary data in MySQL?

Binary data can be stored in Mysql in different ways such as

  • The short length of binary data can be stored in the form of string as a VARCHAR
  • A BLOB data type allows users to store an arbitrary amount of binary data.


In MYSQL Database, data is stored in tabular form and that is why we also call it a Relational Database Management System. With the help of it, users can develop an infinite number of applications but it is mainly used for web applications. Talking about platforms, it can run on various platforms like LINUX, UNIX, and WINDOWS and is reliable, fast, and very easy to use. We hope these questions will help you to clear your core concepts regarding MYSQL. Let us help you with some short and important tips which might help you with your interviews-

  • MYSQL is a programming language, so always avoid YES and NO answers.
  • If you don’t know the answer, simply say I don't know rather than pretending you know.
  • Always carry a pen and notepad with you.
  • If you are stuck somewhere don’t panic, just stay calm and think out loud.
  • Go with the expectation that you will reject a lot, as “Failure is the key to Success”.
Reviewed and verified by Umesh Singh
Umesh Singh

My name is Umesh Singh having 11+ experience in Node.JS, React JS, Angular JS, Next JS, PHP, Laravel, WordPress, MySQL, Oracle, JavaScript, HTML and CSS etc. I have worked on around 30+ projects. I lo...