We have published three articles in the first, second, and third articles in one of the basic questions and answers for Linux interviews, which are well received by readers. At the same time, we have received feedback. Some readers hope that this interactive learning method can be more flexible. We offer you 15 MySQL interview questions.
Recommended articles:
11 basic Linux interview questions
Basic questions about Linux interview-Part 1
Basic questions about Linux interview-Part 1
Question 1: How do you determine whether MySQL is running?
Answer: run the service mysql status command On Debian and the service mysqld status Command on RedHat. Then look at the output.
Root @ localhost:/home/avi # service mysql status
/Usr/bin/mysqladmin Ver 8.42 Distrib 5.1.72, for debian-linux-gnu on istrap
Copyright (c) 2000,201 3, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.
Server version 5.1.72-2
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket/var/run/mysqld. sock
Uptime: 1 hour 22 min 49 sec
Threads: 1 Questions: 112138 Slow queries: 1 Opens: 1485 Flush tables: 1 Open tables: 64 Queries per second avg: 22.567.
Question 2: How do I enable or stop the MySQL service?
Answer: run the Command service mysqld start to enable the service. Run the Command service mysqld stop to stop the service.
Root @ localhost:/home/avi # service mysql stop
Stopping MySQL database server: mysqld.
Root @ localhost:/home/avi # service mysql start
Starting MySQL database server: mysqld.
Checking for creating upt, not cleanly closed and upgrade needing tables ..
Question 3: How to log on to MySQL through Shell?
Answer: run the mysql-u root-p command.
Root @ localhost:/home/avi # mysql-u root-p
Enter password:
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 207
Server version: 5.1.72-2 (Debian)
Copyright (c) 2000,201 3, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.
Type 'help; 'or' \ H' for help. type' \ C' to clear the current input statement.
Mysql>
Question 4: How to list all databases?
Answer: run the show databases command;
Mysql> show databases;
+ -------------------- +
| Database |
+ -------------------- +
| Information_schema |
| A1 |
| Cloud |
| Mysql |
| Phpmyadmin |
| Playsms |
| Sisso |
| Test |
| Ukolovnik |
| Wordpress |
+ -------------------- +
10 rows in set (0.14 sec)
Question 5: How do I switch to a database and work on it?
Answer: run the command use database_name to enter the database named database_name.
Mysql> use cloud;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with-
Database changed
Mysql>