June 8, 2019

Srikaanth

CA Technologies MySQL Interview Questions Answers

CA Technologies MySQL Most Frequently Asked Latest Interview Questions Answers

What is MySQL data directory? How to determine the location of the data directory?

MySQL data directory is most important location in which all MySQL databases are stored. The default data directory is located in the file mysql.

If the out of the space is the issue, then the directory need to be moved another location. Before moving, the database need to be closed. After moving the MySQL configuration file need to be edited. Look for the ‘datadir’ entry and change the path to the new directory.

What you can use Regular Expression for in MySQL? Support your answer with an example.

Regular expressions are a set of characters. Regular expressions are used for finding certain sequences in strings.

The following are the regular expression characters:

- * Represents matching characters that are 0 or more occurrences of the string that precedes it.
- + Represents matching characters that are 1 or more occurrences of the string that precedes it.
- ? Represents matching characters that are 0 or 1 occurrences of the string that precedes it.
- . Represents single character pattern matching.
- [abc] Represents matching characters that is either a or b or c.
- | Used for separation of strings.
- ^ Finds the matching pattern starting from the beginning.

To match the input characters with database tables, REGEXP is used. For example:
Select cityname
from territories
where cityname REGEXP ‘^(jo)*’;

The above query returns all city names that has the substring ‘jo’.
CA Technologies MySQL Most Frequently Asked Latest Interview Questions Answers
CA Technologies MySQL Most Frequently Asked Latest 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 |

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

What does the file with the extension: frm, myd, and myi contain?

MySQL default table type is MyISAM, where there are three kind of files that are stored inside MyISAM. The file names begin with the table name and have the extensions such as frm, myd and myi. The explanation of each file is given below:

.frm file consists of the table definition that are stored in the database
.myd is an extension that is used by a data file.
.myi is an extension that is used by index file.

What is the difference between MYSQL and SQL?

- SQL is known as standard query language, as the name implies it is the language which is used to interact with the database like MySQL.

- MySQL is a database that store various types of data and keep it safe. A PHP script is required to store and retrieve the values inside the database.

How database are managed?

Database is a collection of data and it is managed by a database server, which is a special program that is also known as MySQL database server. Application that you create usually communicates with the database server in the language which it can understand; mostly SQL language is used for communication. Database server in return interacts with the web server on same server or computer. Database server and web server result in the data which is being shown on the web.

What is required to create MYSQL database?

To create MySQL databse the first component which has to be present is a database server on which the queries of database will run and software tool through which you can access the applications. It also requires PHP scripts for communicating with the database using SQL commands.

What do you understand by MYSQL terminal?

MySQL terminal is used as a command line interface in many operating system. It provides a way to access the database and other resources using the SQL commands that are interpreted by the MySQL database server.

Why phpMyAdmin is used for MYSQL?

PhpMyAdmin is a very popular and easy to use GUI tool that can allow SQL commands to be run to create database, create tables, insert data and retrieve it. It provides a web based interface to the user for the ease of use. phpMyAdmin allows user to manage everything from one place and no other installation is required in the computer after this.

Write a query to create a database and a table?

MySQL comes up with some default database that can be used as a base to create a new one. The command that is used to create a new database is as follows:
CREATE DATABASE SQL command

The command has to be written in MySQL terminal. This command will create a new database and then you can create new tables and include data in it.

How can you make a database as your current database?

After making a database the first thing which has to be done is to create a table inside the database to test the new database that is being created. The command which is used to do that is:
USE aliendatabase;

This command allows us to make a database which is not a current database as my current. I have to just use the USE variable and the name of the database and it will become active for use.

What is the difference between a database and a table?

There is a major difference between a database and a table. The differences are as follows:

1. Tables are a way to represent the division of data in a database. Whereas, database is a collection of tables and data.
2. Tables group the data in relation with each other and create a dataset; this dataset will be used in the database. The data which are stored in the table in any form is a part of the database, but opposite is not true.

Subscribe to get more Posts :