The MySQL CLI (Command Line Interface) is a text-based tool where you type commands to interact with the MySQL database directly.
Click to reveal answer
beginner
What is MySQL Workbench used for?
MySQL Workbench is a graphical tool that helps you design, manage, and query MySQL databases using a visual interface instead of typing commands.
Click to reveal answer
beginner
How do you connect to a MySQL server using the CLI?
You use the command: mysql -u username -p and then enter your password when prompted.
Click to reveal answer
beginner
Name one advantage of using MySQL Workbench over the CLI.
Workbench shows database structure visually, making it easier to understand tables and relationships without memorizing commands.
Click to reveal answer
beginner
How do you exit the MySQL CLI?
Type exit; or quit; and press Enter to leave the MySQL CLI.
Click to reveal answer
Which command starts the MySQL CLI?
Amysql connect
Bworkbench start
Cstart mysql
Dmysql -u username -p
✗ Incorrect
The correct command to start the MySQL CLI is mysql -u username -p.
What does MySQL Workbench provide that CLI does not?
AAbility to run SQL queries
BGraphical interface to manage databases
CCommand line access
DFaster server startup
✗ Incorrect
MySQL Workbench offers a graphical interface, unlike the CLI which is text-based.
How do you exit the MySQL CLI?
Aexit;
Bstop;
Cclose;
Dend;
✗ Incorrect
Typing exit; or quit; exits the MySQL CLI.
Which of these is NOT a feature of MySQL Workbench?
ATyping commands in terminal
BRunning SQL queries
CVisual database design
DServer administration
✗ Incorrect
Typing commands in terminal is a feature of the CLI, not Workbench.
What does the '-p' option do in the MySQL CLI command?
APrepares database
BPrints database info
CPrompts for password
DPerforms backup
✗ Incorrect
The '-p' option tells MySQL CLI to ask for your password.
Explain how to connect to a MySQL database using the CLI and how to exit it.
Think about the command to start and the command to leave the CLI.
You got /3 concepts.
Describe the main differences between MySQL CLI and MySQL Workbench.
Consider how you interact with each tool.
You got /4 concepts.
Practice
(1/5)
1. What is the main difference between MySQL CLI and MySQL Workbench?
easy
A. MySQL CLI is command-line based, while Workbench provides a graphical interface.
B. MySQL CLI can only read data, Workbench can only write data.
C. MySQL CLI is used for backups, Workbench is used for queries only.
D. MySQL CLI requires internet, Workbench works offline.
Solution
Step 1: Understand the interface types
MySQL CLI uses text commands typed in a terminal, while Workbench shows windows and buttons.
Step 2: Compare their usage
CLI is purely text-based; Workbench is graphical and easier for beginners.
Final Answer:
MySQL CLI is command-line based, while Workbench provides a graphical interface. -> Option A
Quick Check:
CLI = command-line, Workbench = GUI [OK]
Hint: CLI = text commands, Workbench = visual tool [OK]
Common Mistakes:
Thinking CLI can only read data
Believing Workbench requires internet
Confusing backup and query roles
2. Which of the following is the correct way to start MySQL CLI from a terminal?
easy
A. mysql start
B. start mysql
C. mysql -u root -p
D. run mysql
Solution
Step 1: Recall MySQL CLI startup command
The standard command to start MySQL CLI is 'mysql' with user and password options.
Step 2: Identify correct syntax
'mysql -u root -p' means login as user root and prompt for password.
Final Answer:
mysql -u root -p -> Option C
Quick Check:
Start CLI with 'mysql -u user -p' [OK]
Hint: Use 'mysql -u username -p' to start CLI [OK]
Common Mistakes:
Using 'mysql start' which is invalid
Typing 'start mysql' which is not a command
Forgetting the '-p' to prompt password
3. What will be the output when you run this command in MySQL CLI? SHOW DATABASES;
medium
A. List of all tables in the current database
B. List of all databases on the MySQL server
C. Error: Command not found
D. Empty result set
Solution
Step 1: Understand the command purpose
'SHOW DATABASES;' lists all databases available on the MySQL server.
Step 2: Differentiate from other commands
'SHOW TABLES;' lists tables in current database, so not correct here.
Final Answer:
List of all databases on the MySQL server -> Option B
Quick Check:
'SHOW DATABASES;' = list databases [OK]
Hint: 'SHOW DATABASES;' lists all databases [OK]
Common Mistakes:
Confusing databases with tables
Expecting an error from a valid command
Thinking it returns empty if no database
4. You try to run this command in MySQL CLI: SELECT * FROM users But you get an error. What is the most likely cause?
medium
A. The table 'users' does not exist in the current database
B. Missing semicolon at the end of the statement
C. You forgot to start MySQL Workbench
D. You typed 'SELECT' in lowercase
Solution
Step 1: Check syntax correctness
Missing semicolon usually causes error, but MySQL CLI can accept multi-line input until semicolon is entered.
Step 2: Consider table existence
If 'users' table is missing in current database, query fails with error.
Final Answer:
The table 'users' does not exist in the current database -> Option A
Quick Check:
Missing table = query error [OK]
Hint: Check if table exists before querying [OK]
Common Mistakes:
Assuming lowercase SELECT causes error
Thinking Workbench must be open for CLI
Ignoring missing semicolon impact
5. You want to export a database using MySQL CLI and then open it in MySQL Workbench. Which command correctly exports the database named shopdb to a file backup.sql?
hard
A. mysqlexport -u root -p shopdb backup.sql
B. mysql -u root -p shopdb > backup.sql
C. mysqldump shopdb -u root -p backup.sql
D. mysqldump -u root -p shopdb > backup.sql
Solution
Step 1: Identify the export tool
To export a database, 'mysqldump' is the correct command, not 'mysql'.