top of page

MYSQL

Writer's picture: easSylinuxeasSylinux

Updated: Dec 30, 2017


1) What is MySQL? 


Ans:- MYSQL is an open source relational database management system (RDBMS) based on structured query language


2) What are the technical features of MySQL? 


Ans:- MySQL database software is a client or server system which includes

  • Multithreaded SQL server supporting various client programs and libraries

  • Different backend

  • Wide range of application programming interfaces and

  • Administrative tools.

3) Why MySQL is used?


Ans:- MySQL database server is reliable, fast and very easy to use.  This software can be downloaded as freeware and can be downloaded from the internet.


4) What is the default port for MySQL Server?


Ans:- The default port for MySQL server is 3306.


5) What are the advantages of MySQL when compared with Oracle? 


Ans:-

  • MySQL is open source software which is available at any time and has no cost involved.

  • MySQL is portable

  • GUI with command prompt.

  • Administration is supported using MySQL Query Browser

6) How would you check if MySql service is running or not?


Ans:-


# service mysqld status

 or

#/etc/init.d/mysql  (depend on mysql version )


7) If the service is running/stop how you would stop/start the service?


Ans:-To start MySql service use command as service mysqld start and to stop use service mysqld stop.


8) How will you login to MySQL from Linux Shell?


Ans:- mysql -u root -p.


9) How will you obtain list of all the databases?


Ans:- To list all currently running databases run the command on mysql shell as 

show databases;


10) How will you switch to a database, and start working on that?


Ans:-To use or switch to a specific database run the command on mysql shell as:

use database_name;


11) How will you get the list of all the tables, in a database?


Ans:- To list all the tables of a database use the command on mysql shell as: show tables;


12) How will you delete a table?


Ans:- To delete a specific table use the command on mysql shell as: drop table table_name;


13) What about database? How will you delete a database?


Ans: -To delete a specific database use the command on mysql shell as,

         > drop database database-name;


14)How will you see all the contents of a table?


Ans:- To view all the contents of a particular table use the command on mysql shell as,

        > select * from table_name;


15) Difference between CHAR and VARCHAR? 


Ans:- Following are the differences between CHAR and VARCHAR:

  • CHAR and VARCHAR types differ in storage and retrieval

  • CHAR column length is fixed to the length that is declared while creating table. The length value ranges from 1 and 255

  • When CHAR values are stored then they are right padded using spaces to specific length. Trailing spaces are removed when CHAR values are retrieved.

17) What are the drivers in MySQL?


Ans:- Following are the drivers available in MySQL:

  • PHP Driver

  • JDBC Driver

  • ODBC Driver

  • C WRAPPER

  • PYTHON Driver

18) Tell me some basic SQL commands?


Ans:-


>SHOW  DATABASES;


-to list the database which are available.


>CREATE  DATABASE  <database_name>;


-to create a new database.


>USE <database_name>;


-to connect database.


>SHOW TABLES;


-to list the tables from database.


>SELECT  *  FROM <table_name>;


-to select/read data from database table


>CREATE  TABLE  <table_name> (column);


-to create new table.


>DESCRIBE <table_name>;


-to describe the table information from database.


>INSERT  INTO <table_name> VALUES (data);


-to insert record/data/values into the table.


>DELETE  *  FROM <table_name>;


-to delete record from table.


>DROP   TABLE  <table_name>;


-to delete table from database.


>DROP DATABASE <database_name>;


-to delete database


NOTE- SQL commands are not case sensitive however database name, table and records are case-sensitive.


19) How to start the service of mysql database in Linux?


Ans :- service mysqld start   (in RHEL-6)

           systemctl  start mariadb.service  (in RHEL-7)


20) Explain-   # mysql_secure_installation?


Ans:-This program enables improvement of MYSQL security                                                                    

-sets  a password  for root accounts.                                                                                           

-remove root accounts that are accessible from outside the localhost.                                     

-removes anonymous-user accounts.                                                                                                

-removes the test database.


21) Explain-  # mysql –u root –p?


Ans:-

mysql –> client to connect to theMYSQL database server. 

 –u       -> Option to specify the username for this connection.  

root     -> Username for this connection.                                                                                          

  –p        -> Option to prompt for password.


22) How can I create a user account with MYSQL?


Ans:-   

1st->  connect with MYSQL database server.                                                                         

2nd->CREATE  USER  <user_name>@localhost  IDENTIFIED  BY  ‘password’;


For example- if you want to create a user name natasha with password thankyou then do this,

>CREATE USER natasha@localhost IDENTIFIED BY ‘thankyou’;


23) What is the use of mysqldump command? Any example?


Ans:- we use mysqldump command to take backup of database.


Suppose we want to take a backup of database name “account” into directory   /backup      then we can run command in a following way –


# mysqldump  –u  root  –p  account > /backup/account.dump


-if you want to take backup of all databases  run below command in a following way-


# mysqldump  –u  root  –p   --all-databases > /backup/mysql.dump


24) I take a backup of my database name grras into /backup/grras.dump file but unfortunately someone delete my grras database, now i want to restore that database, How can i?


Ans:- Sir , it’s very simple to restore database , for that you have to create new database or else you can restore it in existing database by using this command.


# mysql  –u  root  –p  grras < /backup/grras.dump


 GOOD LUCK !

48 views0 comments

Recent Posts

See All

HTTPD

1) What does Apache server mean? Ans:- Apache Web Server is designed to create Web servers that have the ability to host one or more...

YUM

1) How to check the installed software (rpm’s) on Redhat Linux ? Ans:- rpm -qa package_name (or) rpm -qa | grep package_name* For...

NFS

1) Why we use NFS server? Ans :- we used NFS (Network File Sharing) server to share a file or a directory over the network but we can...

Comments


Never Miss a Post. Subscribe Now!

connect with us and stay in loop with easSylinux

© easSylinux
bottom of page