Q 1- How to setup admin user for MYSQL ?
Ans:
Login as super user ‘root’ in mysql and execute the following commands.
mysql> use mysql;
mysql> create user ‘test’@'%’ identified by ‘test’;
mysql> grant all on *.* to ‘test’@'%’ with grant option;
mysql> flush privileges;
Q 2- What types of privileges are there in MySQL ?
Ans:
There are 4 types of privileges.
i). Global privileges like *.* (all hosts connecting to Mysql db server)
Example: GRANT SELECT, INSERT ON *.* TO ‘someuser’@'somehost’;
ii). Database privileges like .*
Example: GRANT SELECT, INSERT ON mydb.* TO ‘someuser’@'somehost’;
iii). Table privileges like SELECT, INSERT, UPDATE, DELETE
Example: GRANT SELECT, INSERT ON mydb.mytbl TO ‘someuser’@'somehost’;
iv). Column privileges like
Example: GRANT SELECT (col1), INSERT (col1,col2) ON mydb.mytbl TO ‘someuser’@'somehost’;
Q 3- How to find the version of MySQL ?
Ans:
mysql> select version();
Q 4- How do I limit the number of rows I get out of my database?
Ans:
SELECT name FROM table LIMIT [, ] ;
if you want to get the rows between 10 and 20 do the following:
SELECT name FROM table LIMIT 10, 20 ;
Q 5- Is it possible to insert multiple rows using single command in MySQL ?
Ans:
Yes. Please see below example.
INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9) ;
Q 6- I am getting the following error while logging into “mytest” database.
ERROR 1044 (42000): Access denied for user ‘phpzag’@'localhost’ to database ‘mytest’.
Ans:
Please refer the error to DBA asking for granting the privilege to “mytest” database.
mysql > grant all on test.* to ‘user_name’ @ ‘host_name’ ;
Q 7- What is null value in MySQL ?
Ans:
In MySQL NULL is only equal to NULL, but NULL is not equal to ‘ ‘ ( blank value ) or 0(zero).
Q 8- How can I check if a table in MySQL database already exists?
Ans:
Command : SHOW TABLES LIKE ‘%’;
Q 8- Convert datetime from MST (db servers timezone) into GMT returns NULL value, how to solve it?
Ans:
Database should be updated with timezone value from OS otherwise Mysq
INTERVIEW QUESTIONS, MYSQL