MySQL Interview Questions – Set 05

How will Show all records containing the name “sonia” AND the phone number ‘9876543210’

mysql> SELECT * FROM tablename WHERE name = “sonia” AND phone_number = ‘9876543210’

How to Update database permissions/privilages.

mysql> flush privileges;

how to Return total number of rows

mysql> SELECT COUNT(*) FROM tablename;

How to dump one database for backup.

# [mysql dir]/bin/mysqldump -u username -ppassword –databases databasename >/tmp/databasename.sql

How to delete a database from mysql server

mysql> drop database databasename;

How to Set a root password if there is on root password.

# mysqladmin -u root password newpassword

How you will Create a database on the mysql server with unix shell

mysql> create database databasename;

How does indexing works in MySQL?

Indexing is a process to find an unordered list into an ordered list. It helps in maximizing the query’s efficiency while searching on tables in MySQL. The working of MySQL indexing is similar to the book index.

Suppose we have a book and want to get information about, say, searching. Without indexing, it is required to go through all pages one by one, until the specific topic was not found. On the other hand, an index contains a list of keywords to find the topic mentioned on pages. Then, we can flip to those pages directly without going through all pages.

What is the default port of MySQL Server?

The default port of MySQL Server is 3306.

How to change the column name in MySQL?

While creating a table, we have kept one of the column names incorrectly. To change or rename an existing column name in MySQL, we need to use the ALTER TABLE and CHANGE commands together. The following are the syntax used to rename a column in MySQL:

ALTER TABLE table_name
CHANGE COLUMN old_column_name new_column_name column_definition [FIRST|AFTER existing_column];
Suppose the column’s current name is S_ID, but we want to change this with a more appropriate title as Stud_ID. We will use the below statement to change its name:

ALTER TABLE Student CHANGE COLUMN S_ID Stud_ID varchar(10);