MySQL Workbench
MySQL Workbench is the official GUI tool for MySQL, developed and maintained by Oracle. It combines a visual SQL editor, schema design canvas, server administration panel, and data import/export wizard into a single application. Workbench is free and runs on Windows, macOS, and Linux.
Whether you are writing your first query or designing a complex normalized schema, Workbench provides a productive visual environment that complements the command-line client.
Installing MySQL Workbench
Windows and macOS: Download the installer from dev.mysql.com/downloads/workbench/. Run the installer and follow the wizard — no special configuration is needed.
Ubuntu / Debian:
# Install from Ubuntu's universe repository sudo apt update sudo apt install mysql-workbench-community -y # Or download the .deb package from dev.mysql.com for the latest version # then install it: sudo dpkg -i mysql-workbench-community_8.0.36-1ubuntu22.04_amd64.deb sudo apt install -f # resolve any dependency issues
apt install -f step installs missing dependencies automatically.Connecting to a MySQL Server
When you launch Workbench, the home screen shows your saved connections. To add a new one:
Click the "+" button next to "MySQL Connections" on the home screen.
Give the connection a name (e.g., "Local Dev" or "Production Read Replica").
Set Connection Method to "Standard (TCP/IP)" for most connections.
Enter Hostname (127.0.0.1 for local), Port (3306 is default), and Username (root or your app user).
Click "Store in Keychain" (macOS) or "Store in Vault" (Windows/Linux) to save the password securely.
Click "Test Connection" to verify — a green checkmark means success.
Click OK to save, then double-click the connection card to open it.
Connection types available:
Method | Use Case |
|---|---|
Standard TCP/IP | Direct connection to a MySQL server by hostname and port |
Local Socket/Pipe | Connect via Unix socket (faster than TCP for localhost on Linux/macOS) |
Standard TCP/IP over SSH | Tunnel the MySQL connection through an SSH server — ideal for connecting to production databases securely |
The Workbench Interface
After connecting, Workbench opens the main editor. The interface has several key areas:
Navigator Panel (Left Sidebar)
Schemas tab: Browse all databases on the server. Expand a schema to see Tables, Views, Stored Procedures, and Functions. Right-click any object for a context menu of actions.
Administration tab: Access server status, user accounts, import/export wizard, and configuration variables. This is the GUI equivalent of running SHOW STATUS or editing my.cnf.
Query Editor (Center)
The query editor is where you write and run SQL. Key features:
Syntax highlighting: SQL keywords, table names, and strings are color-coded.
Auto-complete: Press Ctrl+Space to trigger suggestions for table names, column names, and SQL keywords.
Multiple tabs: Open multiple query tabs with Ctrl+T (or Cmd+T on macOS). Each tab has its own connection session.
Execute buttons: The lightning bolt icon runs the entire script; the lightning bolt with a cursor runs only the statement under the cursor.
Keyboard shortcuts: Ctrl+Enter (or Cmd+Enter) executes the current statement. Ctrl+Shift+Enter runs the entire script.
Results Grid (Bottom)
Query results appear in a tabular grid. You can:
Sort results by clicking column headers
Edit cell values directly in the grid and apply changes (for simple single-table SELECT queries)
Export results to CSV, JSON, or HTML using the Export button
View the execution plan and query statistics in the "Execution Plan" and "Query Stats" tabs
Output Panel
The output panel at the bottom shows the execution log: which queries ran, how long they took, affected row counts, and any errors or warnings. This is invaluable for debugging.
Running Queries in Workbench
-- Select the database you want to work with
USE sakila;
-- Basic query — Workbench highlights the statement, press Ctrl+Enter to run it
SELECT actor_id, first_name, last_name
FROM actor
ORDER BY last_name
LIMIT 10;
-- Run multiple statements — select all, then Ctrl+Shift+Enter
CREATE TABLE test_table (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
INSERT INTO test_table (name) VALUES ('Alice'), ('Bob'), ('Carol');
SELECT * FROM test_table;Using the EER Diagram Tool
The EER (Enhanced Entity-Relationship) diagram tool lets you visually design or reverse-engineer your database schema. To reverse-engineer an existing schema into a diagram:
Go to Database menu → Reverse Engineer
Select your connection and click Continue
Choose the schema (database) to import
Workbench reads all table definitions and generates a visual diagram
Tables appear as boxes; foreign key relationships are drawn as lines with crow's foot notation
To create a new schema visually:
Go to File → New Model
Double-click "Add Diagram" to open the canvas
Drag a Table object from the toolbar onto the canvas
Double-click the table to edit columns, types, and constraints
Use the "1:N Relationship" tool to draw foreign key lines between tables
When done, go to Database → Forward Engineer to generate and execute the CREATE TABLE statements
Importing and Exporting Data
Import via Wizard
To import a SQL dump file (e.g., a sample database or production backup):
Go to Server → Data Import
Choose "Import from Self-Contained File" and browse to the .sql file
Select a target schema or create a new one
Click "Start Import"
Check the Import Progress tab for completion status and errors
Export via Wizard
Go to Server → Data Export
Check the schemas and tables you want to export
Choose "Export to Self-Contained File" for a single .sql file
Configure options: include CREATE TABLE, include data (INSERT statements), and whether to add DROP TABLE IF EXISTS
Click "Start Export"
Viewing the Query Execution Plan
One of Workbench's most powerful features for performance optimization is the visual execution plan. After running a query, click the "Execution Plan" tab in the results panel.
Workbench displays a flowchart of how MySQL executed the query: which indexes were used, how many rows were examined, and where the cost was spent. Red nodes indicate expensive full table scans. This is a visual wrapper around the EXPLAIN command.
-- You can also run EXPLAIN directly in the editor EXPLAIN SELECT c.customer_id, c.first_name, COUNT(r.rental_id) AS rental_count FROM customer c JOIN rental r ON c.customer_id = r.customer_id WHERE c.store_id = 1 GROUP BY c.customer_id ORDER BY rental_count DESC;
Managing Users and Privileges
The Administration tab in the Navigator provides a GUI for user management:
Navigate to Administration → Users and Privileges
The left panel lists all MySQL users. Click a user to see their roles and schema privileges
Use "Add Account" to create a new user — set login name, host, authentication type, and password
The "Schema Privileges" tab lets you grant or revoke privileges on specific databases
The "Administrative Roles" tab assigns server-level roles like DBA, MonitorAdmin, or BackupAdmin
Workbench Keyboard Shortcuts
Shortcut (Windows/Linux) | Shortcut (macOS) | Action |
|---|---|---|
Ctrl+Enter | Cmd+Enter | Execute current statement |
Ctrl+Shift+Enter | Cmd+Shift+Enter | Execute all statements in tab |
Ctrl+T | Cmd+T | New query tab |
Ctrl+W | Cmd+W | Close current tab |
Ctrl+Space | Ctrl+Space | Trigger autocomplete |
Ctrl+/ | Cmd+/ | Toggle comment on selected lines |
Ctrl+B | Cmd+B | Auto-format (beautify) SQL |
F2 | F2 | Rename selected object in Navigator |
Workbench vs Command Line
Workbench and the mysql CLI are complementary tools. Use each where it excels:
Task | Recommended Tool |
|---|---|
Browsing schema and table structure | Workbench (visual Navigator) |
Writing and testing ad-hoc queries | Either (Workbench has autocomplete) |
Viewing query execution plans visually | Workbench |
Designing schemas with ER diagrams | Workbench |
Running SQL scripts in CI/CD pipelines | mysql CLI |
Large imports/exports | mysqldump / mysql CLI (faster) |
Remote server administration via SSH | mysql CLI or Workbench SSH tunnel |
Automation and scripting | mysql CLI |