0
0
MySQLquery~5 mins

MySQL CLI and Workbench

Choose your learning style9 modes available
Introduction
MySQL CLI and Workbench help you manage databases easily. CLI lets you type commands directly, and Workbench gives a friendly visual way to work with your data.
You want to quickly run a simple database command.
You prefer typing commands to control your database.
You want to design or visualize your database structure.
You need to run complex queries with help from a graphical interface.
You want to export or import data using easy tools.
Syntax
MySQL
mysql -u username -p

-- or --

Open MySQL Workbench and connect to your database server
In CLI, '-u' means username and '-p' asks for your password.
Workbench provides buttons and menus to run queries and manage databases visually.
Examples
Open MySQL CLI as user 'root' and enter password when asked.
MySQL
mysql -u root -p
Run this query in CLI or Workbench to see all data in the 'employees' table.
MySQL
SELECT * FROM employees;
This lets you save connection details and open a visual interface.
MySQL
Use the 'New Connection' button in Workbench to connect to your database server.
Sample Program
This shows all databases on your MySQL server after you log in using CLI.
MySQL
mysql -u root -p
-- After login, run:
SHOW DATABASES;
OutputSuccess
Important Notes
CLI is fast and good for quick commands but needs you to remember commands.
Workbench is easier for beginners because it shows tables and data visually.
Always keep your password safe and never share it.
Summary
MySQL CLI lets you type commands directly to manage your database.
MySQL Workbench gives a visual way to work with databases and run queries.
Both tools help you see and change your data, but Workbench is more beginner-friendly.