June 17, 2019

Srikaanth

Globant Most Frequently Asked MySQL Interview Questions

Globant Most Frequently Asked Latest MySQL Interview Questions Answers

What are the steps required to view your MYSQL database?

There are certain steps that are required to before you can view MySQL database and they are as follows:

1. Login as database user

example:
[root@ tmp]# mysql -u mysqluser -p sales

2. List all your MySQL databases: use the show command to view the list of all available MySQL databases.

example
To view sales database use the command shown below:

mysql > show databases;
| Database |
| salesdata |
Globant Most Frequently Asked Latest MySQL Interview Questions Answers
Globant Most Frequently Asked Latest MySQL Interview Questions Answers

Write a command to view MySQL database table structure

To view the database table structure describe command is used that provides the list of all the data fields used in the database table.

Example

A table named sales will have the four fields like: name, description, num and date.

mysql > describe test;
| Field | Type | Null | Key | Default | Extra|
| num | int(11)| |PRI | NULL | auto_increment |
| date | date| | MUL | 0000-00-00 |
| name | varchar(50) | MUL |
| description | varchar(75) | YES | | NULL

Write a command to view the content of the table

To view all the data that is contained inside a table named sales use the select command. For example: to see the data of first row in a table using the command as:
mysql > select * from sales limit 1;

If the database is created recently then it will give a blank listing, but after the data is being entered it will show the full listing in a tabular form.

What is the procedure to configure the application of MYSQL?

The procedure to configure the application of MySQL is:

1. First create a database
2. Test the database by informing about the database name, IP address of database client server, username and password of application.
3. Edit the special application specific configuration file using a GUI or command line.
4. Configure the language with which MySQL will interact.

What are the applications required to support MYSQL?

The applications that are required to support MySQL are as follows:

1. php-mysql MySQL database is used specifically to support PHP
2. perl-DBI : provides generic Perl interface for interacting with relational databases
3. perl-DBD-MySQL database specific support for Perl
4. Web server is required to configure the database and its configuration
5. Programming language is required which supports MySQL.

Write a query to stop MYSQL in unix

The query to stop MySQL is quite useful when an error is occurred or when data has to be saved from any mishap. It is also used for retrieving the root password because it is either easily forgotten or misplaced. To stop the service the following command is required:
Stop MySQL
[root@ tmp]# service mysqld stop
Stopping MySQL: [ OK ]
[root@ tmp]#

Write a query to MYSQL in safe mode and to change the root password

To start MySQL in safe mode, mysqld_safe command is used which allow it to run in the safe mode and it also doesn’t allow the reading of tables with the database passwords:
[root@ ]# mysqld_safe --skip-grant-tables --skip-networking &[1] 13007
[root@ ]# Starting mysqld daemon with databases from /var/lib/mysql
[root@ ]#

After running the MySQL in safe mode the password protection gets removed and to use the password protection mechanism a command is used as follows:
mysql -u root command
[root@bigboy tmp]# mysql -u root

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.16
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> [ a message is being shown which allow user to take the control of the root]

How to take MYSQL database backup?

To take the database backup use the following syntax:
mysqldump --add-drop-table -u [username] -p[password] [database] > [backup_file]

This command will take the database backup by knowing the username and password for the database connection and dropping any table which is being deleted or not in use. It is always a good practice to take the backup of mysql as it contains all the database information that a user can access. While using the command keep a note that there should not be any space between –p switch and password, if there is then you will get a syntax error.

Write a command with which MySQL table can be repaired

The command syntax with which mysql table can be repaired is as follows:
REPAIR TABLE tablename;
REPAIR TABLE tablename QUICK;
REPAIR TABLE tablename EXTENDED;

The command will just do as it says repair a specified table, but if QUICK or EXTENDED is used then the meaning of it changes. In case of QUICK it will repair only the index tree, whereas in case of EXTENDED it will create index row by row and repair it.

What are the different tables present in MySQL?

There are many tables that remain present by default. But, MyISAM is the default database engine used in MySQL. There are five types of tables that are present:

1. MyISAM
2. Heap
3. Merge
4. INNO DB
5. ISAM.

Subscribe to get more Posts :