MySQL + SQL · Lesson 32
MySQL Command Line Basics
Using the MySQL CLI
The MySQL command-line client lets you run SQL directly in the terminal.
Connecting
mysql -u root -p
# enter your password when asked
Useful CLI Commands
| Command | Does |
|---|---|
| SHOW DATABASES; | list databases |
| USE school; | select a database |
| SHOW TABLES; | list tables |
| DESC students; | show table structure |
| \q or EXIT; | quit |
Summary
- Connect with
mysql -u root -p. - USE selects a DB; SHOW/DESC explore it; EXIT quits.