Part · Chapter

Clients and tools

Every database client, from a bare command prompt to a big GUI, does one job: it sends SQL text to the server and shows you the rows that come back.

The short version

  • A client is a messenger. It sends SQL text and shows the rows the server sends back.
  • Pick by task. Command line for quick checks and scripts, a GUI to browse and click.
  • If you install one GUI, install DBeaver Community. It is free and speaks both engines.
  • Five facts make a connection. Host, port, user, database, TLS.
  • Load sample data. An empty server teaches nothing, so start with shop.
  • Docker gives you a throwaway server. One line to start it, one line to delete it.

One idea: a client is a messenger

The server owns the data: mysqld.exe for MySQL, postgres.exe for PostgreSQL. A client is anything that connects, sends a statement and reads the result, so the mysql prompt, Workbench, DBeaver and your company's web application are all clients. What differs between them is convenience; chapter 2 traced the rest of the path.

Remember

A query behaves the same wherever you type it. A GUI button is a statement you did not have to type, so when a tool falls short, ask an AI assistant for the SQL.

MySQL clients

ToolBest forNote
mysql command lineQuick checks, one-line statements, running a .sql file, Task Scheduler jobsFree, ships with the server in C:\Program Files\MySQL\MySQL Server X.Y\bin, which chapter 4 added to PATH.
MySQL Shell 26.7.1 (mysqlsh)Dumps and loads, upgrade checks, InnoDB ClusterFree, separate download. One version serves 8.4, 9.7 and 26.7 servers; starts in SQL mode.
MySQL Workbench 26.7Browsing a schema, editing queries, visual EXPLAIN (chapter 10), administration pagesFree, dev.mysql.com/downloads/workbench. A new Electron app built on MySQL Shell, for 8.4 and newer. Needs the Visual C++ 2019 runtime.
MySQL Workbench 8.0.47Nothing newThe last release of the old line, declared end of life. Tutorials, screenshots and the manual still show it, so expect a mismatch.
HeidiSQLEditing rows in a grid, exporting to CSV or SQL, copying a table between serversFree, open source, Windows-native, opens in a second. Also MariaDB, PostgreSQL, SQL Server and SQLite.
DBeaver Community 26.2.xBoth engines in one window, ER diagrams from existing tables, schema compare, data transferFree, Apache 2.0, Java and JDBC. The data transfer wizard copies tables between engines (chapter 17).
VS Code SQLToolsSQL next to your codeFree, open source, with separate driver extensions per engine. The old MySQL Shell for VS Code extension is discontinued; its features moved into Workbench 26.
Percona PMMGraphs and dashboards for both enginesFree, open source, runs as Linux containers (Docker Desktop with WSL 2). No Windows agent, so it watches a Windows MySQL as a remote instance.
PowerShell
# One statement, then exit. -p with no value prompts for the password.
mysql -u root -p shop -e "SELECT id, name, city FROM customers"

Careful

Every MySQL tutorial loads a file with mysql -u root -p < file.sql, and in PowerShell that fails, because PowerShell reserves <. Hand the line to cmd.exe /c "...", or type source C:/path/file.sql inside mysql; for mysqldump, use --result-file= instead of >, which also keeps line endings from becoming CRLF.

MySQL Shell (mysqlsh): the modern one

Behind \js and \py are the utilities a DBA installs it for. util.dumpInstance(), util.dumpSchemas() and util.loadDump() write parallel, compressed dumps, which Oracle's manual prefers to mysqldump for anything large (chapter 15). util.checkForServerUpgrade() finds what will break in the next version, and dba.* and cluster.* build InnoDB Cluster, ClusterSet and ReplicaSet.

Illustration · MySQL
mysqlsh root@localhost:3306/shop
SELECT status, COUNT(*) FROM orders GROUP BY status;
\js
util.dumpSchemas(["shop"], "C:/backups/shop-2026-09-27", {threads: 4})
util.checkForServerUpgrade()
\sql

Paid Enterprise tools, and the free alternatives

MySQL Enterprise Backup (mysqlbackup, hot physical InnoDB backups) is paid Enterprise Edition only, and MySQL Enterprise Monitor reached end of life on January 1, 2025. Your free backup options are mysqldump, the Shell dump utilities, the Clone plugin and the binary log; mysqlpump was removed in 8.4 and Percona XtraBackup does not run on Windows. Free monitoring is the Performance Schema and sys schema (chapter 16), plus PMM for graphs.

PostgreSQL clients

ToolBest forNote
psqlQuick checks, running a file, scripts and scheduled jobsFree, comes with the EDB installer from chapter 5, in C:\Program Files\PostgreSQL\18\bin.
pgAdmin 4 9.18Object browser, Query Tool with an EXPLAIN visualizer, session and lock dashboards, role dialogsFree. A web app in a desktop window, so it asks for a master password. Its Backup and Restore dialogs run pg_dump and pg_restore and show you the command; copy that into a script. The installer bundles an older copy than the standalone build.
DBeaver Community, HeidiSQLPostgreSQL in the same window as MySQLBoth connect natively. If your PostgreSQL work is occasional, you may never need pgAdmin.
VS Code PostgreSQL extensionObject explorer, IntelliSense, plan viewing, a Copilot chat participantFree, Microsoft's own (ms-ossdata.vscode-pgsql), generally available since late 2025, PostgreSQL only.

psql: the command line, with backslash commands

Anything that starts with a backslash is a meta-command that psql handles itself; everything else goes to the server. They are wrappers over the catalog tables, like MySQL's SHOW TABLES.

CommandWhat it doesMySQL equivalent
\lList databasesSHOW DATABASES
\c shopConnect to database shopUSE shop
\dtList tables in the current databaseSHOW TABLES
\d ordersDescribe a table: columns, indexes, foreign keysDESCRIBE orders / SHOW CREATE TABLE
\duList roles (users)SELECT user, host FROM mysql.user
\xToggle expanded output (one column per line)end a statement with \G
\timingShow how long each statement tookshown after every statement by default
\i C:/path/file.sqlRun a filesource C:/path/file.sql
\qQuitexit
Illustration · PostgreSQL
psql -U postgres -d shop
\dt
\d orders
SELECT id, customer_id, status, total FROM orders WHERE customer_id IS NULL;
\q

Three Windows details, because Linux advice will mislead you. There is no postgres operating-system user (the service runs as Network Service), so you always run psql -U postgres with a password. A plain console prints a code-page warning, so run chcp 1252 first. And psql connects over TCP to localhost, so only the host ... 127.0.0.1/32 and ::1/128 lines of pg_hba.conf matter locally.

Connecting: the five things every client asks for

Every dialog and command line asks the same five questions, as flags or packed into one URI. MySQL adds a twist: an account is a user and a host pattern, so 'app'@'localhost' and 'app'@'%' are two different accounts. Chapter 14 covers that and connecting from another machine.

What it asksMySQLPostgreSQL
Hostlocalhost or 127.0.0.1 for your own machine
Port3306 (X Protocol 33060)5432
Useruser plus host patterna role
Database to land ina database is called a schemadatabases contain schemas (chapter 17)
SSL/TLS--ssl-mode=REQUIRED; 8.4 generates its own certificates at first startsslmode=require
Saved password.mylogin.cnf in %APPDATA%\MySQLpgpass.conf in %APPDATA%\postgresql
PowerShell
# Flags, then a URI. Both clients fall back to plain text unless you require TLS.
mysql -h 127.0.0.1 -P 3306 -u app -p --ssl-mode=REQUIRED shop
mysqlsh app@db01.example.internal:3306/shop
mysql_config_editor set --login-path=local --host=localhost --user=root --password
# psql: lowercase -p is the port, -U is the user
psql -h 127.0.0.1 -p 5432 -U app -d shop
psql "postgresql://app@db01.example.internal:5432/shop?sslmode=require"

Grids run real SQL: editing a cell and clicking Apply sends an UPDATE that autocommit commits on the spot (chapter 9). Browse production with a read-only account, and give that connection its own color.

For you as a DBA

Half of "the database is down" tickets are one of these five facts being wrong: a changed port, an account created for localhost used from a web server, a missing firewall rule, or an old driver that only knows the removed mysql_native_password plugin. Get the exact error text first; it usually names which one.

Sample databases worth loading

An empty server teaches nothing. Load shop first, and a bigger one when you want to feel what an index does on a million rows.

DatabaseEngineWhat is in itGet it
shopBothCustomers, products, orders, order items, and a small tracks table of album tracks. The course dataset.assets/sample-shop.mysql.sql, assets/sample-shop.postgres.sql
sakilaMySQLA DVD rental store: 16 tables, views, stored procedures, triggers. The Configurator can install it for you.sakila-db.zip
worldMySQLCountries, cities and languages in three tables. Small and quick.world-db.zip
employeesMySQLAbout 300,000 employees and 2.8 million salary rows. Big enough that a missing index hurts.github.com/datacharmer/test_db
pagilaPostgreSQLA port of sakila to PostgreSQL, with full-text search and JSONB variants.github.com/devrimgunduz/pagila
dvdrentalPostgreSQLAnother DVD store: 15 tables, 7 views, 8 functions, 1 trigger. A pg_dump archive, so you restore it.dvdrental.zip
chinookBothA digital media store (artists, albums, tracks, invoices). One script per engine.Chinook release assets

The full MySQL list, including the 625 MB airportdb, is at dev.mysql.com/doc/index-other.html. Each sample creates its own database; sakila comes as two files, and employees must be run from inside its unzipped folder, because it pulls in data files by relative path.

PowerShell
# MySQL. The course dataset creates database "shop".
cmd.exe /c "mysql -u root -p < assets\sample-shop.mysql.sql"
cmd.exe /c "mysql -u root -p < sakila-schema.sql"
cmd.exe /c "mysql -u root -p < sakila-data.sql"
cmd.exe /c "mysql -u root -p < employees.sql"
PowerShell
# PostgreSQL. shop and Chinook create their own database, so no -d.
psql -U postgres -f assets/sample-shop.postgres.sql
psql -U postgres -c "CREATE DATABASE pagila"
psql -U postgres -d pagila -f pagila-schema.sql
psql -U postgres -d pagila -f pagila-data.sql
# dvdrental is a pg_dump archive, so pg_restore, not psql
psql -U postgres -c "CREATE DATABASE dvdrental"
pg_restore -U postgres -d dvdrental C:\samples\dvdrental.tar

Ask the AI

You do not need to remember dump options: "MySQL 8.4 on Windows 11: give me the exact mysqlsh commands to dump only the shop schema to C:\backups with 4 threads, then load it into a fresh 8.4 server, including any server setting the load needs."

Throwaway instances: Docker and online sandboxes

Your installed server is where you practice DBA work. Sometimes you want a second one to test a restore, run 9.7 next to 8.4, or break something on purpose.

PowerShell
# MySQL 8.4 LTS on host port 3307 (tags mysql:9.7 and mysql:26.7 also exist)
docker run --name mysql84 -e MYSQL_ROOT_PASSWORD=ChangeMe1 -p 3307:3306 -d mysql:8.4
mysql -h 127.0.0.1 -P 3307 -u root -p
# PostgreSQL 18 on host port 5433 (postgres:17 for the older major)
docker run --name pg18 -e POSTGRES_PASSWORD=ChangeMe1 -p 5433:5432 -d postgres:18
psql -h 127.0.0.1 -p 5433 -U postgres
# Done experimenting? This deletes the containers and their data.
docker rm -f mysql84 pg18

Docker Desktop uses WSL 2 under the hood. Map the container port to a spare host port if your real service owns 3306 or 5432, then connect with your normal client. Oracle builds its MySQL images for Linux and calls running them elsewhere "at your own risk", fine for a learning instance. Image pages: hub.docker.com/_/mysql and hub.docker.com/_/postgres.

Browser sandboxes answer "does this syntax work in 8.4?" without installing anything. They are query-only, and none runs the 26.x line yet, so treat them as scratch paper; chapter 18 has the gamified practice sites.

SandboxWhat it runs
db<>fiddleMySQL 5.5 through 9.7 and PostgreSQL 8.4 through 18. The best place to compare versions.
DB FiddleA different site: MySQL 9.5 and 8.4, PostgreSQL, MariaDB, SQLite. Shareable links.
SQLize.onlineMySQL 8.0, 8.4 and 9.7 plus PostgreSQL 15 to 18. Its Sakila variant is MySQL 8.0 and read-only.
SQLite OnlineDespite the name, also MySQL/MariaDB and PostgreSQL. Not for personal data, as its own terms say.
OneCompiler MySQL, Codapi MySQLMinimal editors, no account, fine for a five-line experiment.
SQL Fiddle, RunSQLMySQL, PostgreSQL and SQL Server; RunSQL adds a visual schema builder.
phpMyAdmin demoLog in as root with an empty password to relearn the web GUI many hosting panels still use. Resets every hour.

Skip W3Schools' "MySQL Tryit": it is not a MySQL server, and modern browsers only give it a read-only fallback.

Which tool when

TaskMySQLPostgreSQL
Ad-hoc querymysql or MySQL Shell for a fact; Workbench, HeidiSQL or DBeaver to look at resultspsql for a fact; pgAdmin Query Tool or DBeaver to look at results
Browse a schema you did not designWorkbench, DBeaver (ER diagram), HeidiSQLpgAdmin object browser, DBeaver, \d in psql
Backup and restoreMySQL Shell util.dumpInstance() / util.loadDump(); mysqldump for small or plain-SQL dumps; binary log for point in timepg_dump / pg_restore, pg_basebackup; pgAdmin's Backup dialog runs them for you
Users and grantsCREATE USER / GRANT in any client; Workbench administration pagesCREATE ROLE / GRANT in psql; pgAdmin role dialogs; pg_hba.conf for who may connect
MonitoringPerformance Schema and sys views, SHOW PROCESSLIST; Workbench status page; PMM or Grafana for dashboardspg_stat_activity, pg_stat_statements; pgAdmin dashboard; PMM
Scripting and automationmysql -e or a .sql file from Task Scheduler, credentials via --login-path; mysqlsh with JavaScript or Python for logicpsql -f or -c from Task Scheduler, password from pgpass.conf; PowerShell around it
Upgrade readinessmysqlsh util.checkForServerUpgrade()pg_upgrade --check
Copy data between the two enginesDBeaver's data transfer wizard, in either direction

If a task is not in this table, it is still SQL or a command-line utility, so ask: "MySQL 9.7 on Windows 11, which tool and which exact command does this?"

Quick check

1. You need a fast, parallel, compressed dump of a 200 GB MySQL 9.7 database. Which tool is the one Oracle's manual points you to?

MySQL Shell's dump utilities dump with several threads at once and compress the files, and the mysqldump manual page itself points you to them. mysqldump still works but is single-threaded plain SQL, and mysqlpump was removed in 8.4. Reread "MySQL Shell (mysqlsh): the modern one".

2. In psql, which command lists the tables in the database you are connected to?

\dt lists tables; \l lists databases and \du lists roles. SHOW TABLES is MySQL syntax and PostgreSQL rejects it. Reread "psql: the command line, with backslash commands".

3. Your employer runs MySQL Community Edition on Windows. Which of these can you actually use for free on that server?

Enterprise Backup is paid, Enterprise Monitor reached end of life in January 2025, and XtraBackup only runs on Linux. DBeaver Community is free and works with both engines. Reread "Paid Enterprise tools, and the free alternatives".

4. In PowerShell, mysql -u root -p < shop.sql fails before the password prompt even appears. Why?

PowerShell does not implement input redirection with <, so the command is rejected by the shell, not by MySQL. Use cmd.exe /c "mysql -u root -p < shop.sql" or source from the mysql prompt. Reread the "Careful" note under "MySQL clients".