Setting Up the MySQL Environment
Learn the two main ways you will interact with MySQL throughout this course, and practice the basic command-line client commands.
Introduction
You now have both MySQL Server and MySQL Workbench installed. Before diving into real database concepts, it helps to get comfortable moving around MySQL itself — checking what databases exist, switching between them, and exiting cleanly.
This lesson is a short, practical setup step: a primer on the handful of commands you will use constantly, in either the command-line client or Workbench's SQL editor, throughout the rest of this course.
- The two main ways you will interact with MySQL in this course.
- How to list all databases on a server.
- How to switch into a specific database.
- How to list the tables inside a database.
- How to exit the command-line client cleanly.
- How to set up a consistent practice environment going forward.
Two Ways to Work With MySQL
Throughout this course, you can follow along using either of the two tools you have already installed. Both send exactly the same SQL to exactly the same MySQL server — they are just different front doors into it.
Command-Line Client
- Text-based, works over `mysql -u root -p`.
- Fast and lightweight, no GUI required.
- Great for quick checks and scripting.
- Available on every operating system.
MySQL Workbench
- Visual, with a schema sidebar and results grid.
- Easier to read multi-row results.
- Good for browsing table structures visually.
- Saves and organizes queries conveniently.
This course will mostly show SQL in the command-line style, since it is the simplest to reproduce exactly, but every query works identically if you paste it into MySQL Workbench's SQL editor instead.
Basic Command-Line Commands
Before you connect, open a terminal (or Command Prompt) and log in the same way you did to verify your installation.
mysql -u root -pOnce you see the mysql> prompt, you are ready to type SQL and a handful of special client commands. Note that every SQL statement must end with a semicolon (;).
Listing Databases
The SHOW DATABASES command lists every database that currently exists on the server you are connected to.
SHOW DATABASES;+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+On a fresh installation, you will typically see these four system databases. They are used internally by MySQL and are not something you need to modify — the databases you create later in this course will appear alongside them in this same list.
Selecting a Database
A single MySQL server can host many databases at once, so before running queries against tables, you need to tell MySQL which database you mean. The USE command switches your active database.
USE mysql;Database changedFrom this point on, any query you run (like SHOW TABLES) will apply to the mysql database specifically, until you USE a different one.
Listing Tables
Once inside a database, SHOW TABLES lists every table that database contains.
SHOW TABLES;+---------------------------+
| Tables_in_mysql |
+---------------------------+
| db |
| user |
| ... (many system tables) |
+---------------------------+This is exactly the pattern you will repeat over and over in this course: SHOW DATABASES to see what exists, USE a database to select it, and SHOW TABLES to see what is inside it.
Exiting the Client
When you are done working in the command-line client, type exit (or quit) to close the connection cleanly and return to your regular terminal.
exitByeUnlike most SQL statements, exit and quit do not need a trailing semicolon, since they are special client commands rather than SQL sent to the server.
Setting Up Your Practice Environment
To get the most out of this course, keep a terminal (or MySQL Workbench) open and ready every time you go through a lesson, and actually type out each example yourself rather than only reading it.
Keep Credentials Handy
Have your root username and password ready to log in quickly each session.
Use a Practice Database
Later lessons will have you create a dedicated database to safely experiment in.
Type, Do Not Just Read
Typing each query yourself builds muscle memory far faster than reading alone.
Repeat the Basics
Practice SHOW DATABASES, USE, and SHOW TABLES until they feel automatic.
What's Next
With your environment ready and the basic navigation commands under your belt, the next lesson shifts from tooling to concepts: what a database actually is at a deeper level, before you start creating real ones and writing real queries.
Common Mistakes
- Forgetting the trailing semicolon at the end of SQL statements.
- Running SHOW TABLES before selecting a database with USE, and being confused by the error.
- Closing the terminal window abruptly instead of typing exit.
- Mixing up SHOW DATABASES (lists databases) with SHOW TABLES (lists tables inside one database).
Best Practices
- Always confirm which database is active before running queries, especially early on.
- Practice the SHOW DATABASES → USE → SHOW TABLES pattern until it feels natural.
- Use whichever tool, command line or Workbench, helps you learn fastest — both are equally valid.
- Exit cleanly with exit or quit rather than force-closing your terminal.
Frequently Asked Questions
Do I have to pick one tool, command line or Workbench, and stick with it?
No. You can freely switch between them at any point in this course — they both talk to the same MySQL server using the same SQL.
Why did SHOW TABLES return an error?
This usually means no database has been selected yet. Run USE followed by a database name first.
Do SQL keywords need to be typed in uppercase?
No, MySQL keywords are not case-sensitive, but writing them in uppercase (like SELECT, USE, SHOW) is a common convention that makes queries easier to read.
What happens if I forget the semicolon at the end of a statement?
The command-line client will keep waiting for more input on a new line (shown by a "->" prompt) until it sees a semicolon, since that is what tells it the statement is complete.
Is it safe to explore the system databases like mysql or sys?
You can look inside them safely with SHOW TABLES and SELECT queries, but avoid modifying their contents, since they support MySQL's own internal operation.
Key Takeaways
- This course can be followed using either the command-line client or MySQL Workbench.
- SHOW DATABASES; lists every database on the server.
- USE database_name; selects which database your queries apply to.
- SHOW TABLES; lists the tables inside the currently selected database.
- exit (or quit) closes the command-line client cleanly.
- A consistent practice environment, with credentials handy and a habit of typing queries yourself, will speed up your learning.
Summary
With MySQL and MySQL Workbench installed, and the basic navigation commands — SHOW DATABASES, USE, SHOW TABLES, and exit — comfortably in hand, you have everything you need to start exploring real database concepts.
In this lesson, you learned the two ways to work with MySQL in this course, practiced the essential command-line basics, and set up a consistent environment for practicing going forward. Next, you will dive into understanding what a database really is, before creating and querying your own.
- You know the two main ways to work with MySQL in this course.
- You can list databases, switch into one, and list its tables.
- You know how to exit the command-line client cleanly.
- You have a practice environment ready for the rest of the course.