1. What is MySQL?
A) MySQL is an open-source Relational Database Management System (RDBMS) that uses SQL (Structured Query Language) for storing, retrieving, and managing data.
2. What is the difference between MySQL and SQL?
A)
- SQL → A query language used to interact with databases.
- MySQL → A database management system that implements SQL.
3. How do you create a new database in MySQL?
A)
CREATE DATABASE company;
4. How do you create a new user in MySQL?
A)
CREATE USER 'john'@'localhost' IDENTIFIED BY 'password123';
5. How do you grant privileges to a MySQL user?
A)
GRANT ALL PRIVILEGES ON company.* TO 'john'@'localhost'; FLUSH PRIVILEGES;
6. What is the difference between CHAR and VARCHAR in MySQL?
A)
- CHAR(n) → Fixed length, always reserves space (faster, wastes storage).
- VARCHAR(n) → Variable length, stores only actual characters (saves space).
7. How do you find all databases in MySQL?
A)
SHOW DATABASES;
8. How do you find all tables in a database?
A)
SHOW TABLES FROM company;
9. How do you view the structure of a table in MySQL?
A)
DESCRIBE employees;
or
SHOW COLUMNS FROM employees;
10. How do you take a backup of a MySQL database?
A)
mysqldump -u root -p company > company_backup.sql
11. How do you restore a MySQL database backup?
A)
mysql -u root -p company < company_backup.sql