Mysql Interview Questions And Answers

mysql interview questions and answers   Top 26 Mysql Interview Questions And Answers

1) What is MySQL?

MySQL is the most popular Open Source Relational SQL Database Management System.


2) Why MySQL?

Following are the reasons why it is so popular:

● MySQL is a fast database
● It is easy to use RDBMS which is being used by both big or small organizations
● It is open source so it is free to use
● It works well with all the operating systems and many languages including PHP, PERL, C, C++, JAVA, etc.
● It works quickly and effectively with large datasets.
● MySQL is customizable according to the organizations need.


3) How to encrypt the password for new user in MySQL?

Whenever adding new user in MySQL their password can be using function password().


4) What is the use of FLUSH PRIVILEGES command in MySQL?

FLUSH PRIVILEGES statement tells the server to reload the grant tables.


5) What are the different privileges in MySQL?

Following are the privileges which can be given to the new user:

● Select_priv
● Insert_priv
● Update_priv
● Drop_priv
● Delete_priv
● Create_priv
● Process_priv
● Reload_priv
● Shutdown_priv
● Grant_priv
● File_priv
● Index_priv
● References_priv
● Alter_priv


6) What are the different Administrative commands in MySQL?

Following are the different Administrative commands in MySQL:

● USE Databasename
● SHOW DATABASES
● SHOW TABLES
● SHOW INDEX FROM tablename
● SHOW COLUMNS FROM tablename
● SHOW TABLE STATUS LIKE tablename


7) How we can establish MySQL Connection Using MySQL Binary?

Here is the command which is used to establish MySQL Connection Using MySQL Binary:

[root@host]# mysql -u root -p
Enter password:***


8) How to connect to MySQL database using PHP?

Here is the command which is used to connect to MySQL database:

connection mysql_connect(server,user,passwd,new_link,client_flag);


9) How to close MySQL database connection using PHP?

Here is the command which is used to close MySQL database connection:

bool mysql_close ( resource $link_identifier );


10) How to Create Database Using mysqladmin in MySQL?

Here is the syntax:

mysqladmin -u root -p create


11) How to drop Database Using mysqladmin in MySQL?

Here is the syntax:

mysqladmin -u root -p drop


12) Which are the different data types in MySQL?

Following are the three major data types in MySQL:

● Numeric
● Date and Time
● String Types


13) Which are the different data types comes under Numeric in MySQL?

Following are the data types under numeric:

● INT
● TINYINT
● SMALLINT
● MEDIUMINT
● BIGINT
● FLOAT
● DOUBLE
● DECIMAL


14) Which are the different data types comes under Date and time in MySQL?

Following are the data types under date and time:

● DATE
● DATETIME
● TIMESTAMP
● TIME
● YEAR(M)


15) Which are the different data types comes under string in MySQL?

Following are the data types under string:

● CHAR
● VARCHAR
● BLOB or TEXT
● TINYBLOB or TINYTEXT
● MEDIUMBLOB or MEDIUMTEXT
● LONGBLOB or LONGTEXT
● ENUM


16) How to create MySQL table?

Here is the syntax:

CREATE TABLE table_name (column_name column_type);


17) How to drop MySQL table?

Here is the syntax:

DROP TABLE table_name;


18) How to insert into MySQL table?

Here is the syntax:

INSERT INTO table_name ( field1, field2,...fieldN )
   VALUES
   ( value1, value2,...valueN );


19) How to select data from MySQL table?

Here is the syntax:

SELECT field1, field2,...fieldN 
FROM table_name1, table_name2...
[WHERE Clause]
[OFFSET M ][LIMIT N]


20) How to update data in MySQL table?

Here is the syntax:

UPDATE table_name SET field1 = new-value1, field2 = new-value2
[WHERE Clause]


21) How to delete data from MySQL table?

Here is the syntax:

DELETE FROM table_name [WHERE Clause]


22) How to use like while selecting data from MySQL table?

Here is the syntax:

SELECT field1, field2,...fieldN table_name1, table_name2...
WHERE field1 LIKE condition1 [AND [OR]] filed2 = 'value'


23) How to sort data in MySQL table?

Here is the syntax:

SELECT field1, field2,...fieldN table_name1, table_name2...
ORDER BY field1, [field2...] [ASC [DESC]]


24) What is IS NULL operator in MySQL?

This operator returns true, if the column value is NULL.


25) What is IS NOT NULL operator in MySQL?

This operator returns true, if the column value is not NULL.


26) What is <=> operator in MySQL?

This operator compares values.