Installing PostgreSQL / MySQL & Database Clients (DBeaver, pgAdmin)
Install a local engine, connect with a GUI client, and run your first query safely.
In plain words
Install the database, install a program that talks to it, and connect them with an address and a password.
Think of it like…
The database server is the library and the client is your library card plus the catalogue terminal: the books live in the library, and the terminal is how you ask for them. The connection string is the library's address and your card number.
Where you’ve seen it
A candidate preparing for a data-analyst interview runs docker run --name pg -e POSTGRES_PASSWORD=change_me -p 5432:5432 -d postgres:18, connects DBeaver to localhost:5432, loads a sample e-commerce dataset with psql -h localhost -U postgres -f shop.sql, and practises window-function questions against realistic tables.
Words you’ll hear
- Server
- The running database process (postgres, mysqld) that stores data and executes queries.
- Client
- A program that connects to the server and sends SQL: psql, mysql, DBeaver, pgAdmin.
- Port
- PostgreSQL listens on 5432 by default, MySQL on 3306.
- Connection string
- Host, port, database and user in one URL, such as postgresql://user@host:5432/db.
Visual diagram
Theory & example queries
Installing a local server
Docker is the most repeatable option on any operating system: docker run --name pg -e POSTGRES_PASSWORD=change_me -p 5432:5432 -v pgdata:/var/lib/postgresql -d postgres:18 starts PostgreSQL with data kept in a named volume, and docker run --name mysql -e MYSQL_ROOT_PASSWORD=change_me -p 3306:3306 -d mysql:8.4 does the same for MySQL. Without Docker, use Postgres.app or Homebrew on macOS, the official installers on Windows, or the distribution's packages (apt install postgresql) on Linux.
Check it works from the command line before reaching for a GUI: psql -h localhost -U postgres then SELECT version();. In psql, \l lists databases, \c shop switches database, \dt lists tables, \d orders describes a table and \q quits. The MySQL equivalents are SHOW DATABASES;, USE shop;, SHOW TABLES; and DESCRIBE orders;.
CREATE DATABASE shop;CREATE USER analystWITH PASSWORD 'change_me';GRANT pg_read_all_data TO analyst;PostgreSQL is the lesson baseline unless noted otherwise.
Identify the table or database object the statement will modify.
Representative PostgreSQL command status
Note: Assumes PostgreSQL 14+, an authorized superuser session, and names that do not already exist. pg_read_all_data grants read-only access to all user tables and views.
(a built-in read-only role in PostgreSQL 14+), then connect with psql postgresql://analyst@localhost:5432/shop.
Key takeaway: Docker for a repeatable server; psql or mysql to confirm it works.
GUI clients and safe habits
DBeaver is free and connects to almost any database; pgAdmin is PostgreSQL's own tool; MySQL Workbench is MySQL's; DataGrip and TablePlus are popular paid options. All of them give you a schema browser, a query editor with autocomplete, result grids you can export, and ER diagrams of existing tables. To practise, load a sample dataset such as Pagila (PostgreSQL) or Sakila (MySQL), or import CSVs with COPY or LOAD DATA.
Good habits start locally. Most GUIs autocommit each statement, so an UPDATE without WHERE is permanent; for risky changes run BEGIN; first and check the row count before COMMIT;. Name and colour-code connections so a production connection looks different, connect to production with a read-only user, and never paste production passwords into shared files; use the client's credential store or environment variables.
| id | name | price | category | stock |
|---|---|---|---|---|
| 42 | SQL Notebook | 49.5 | books | 18 |
| 84 | Mechanical Keyboard | 150 | hardware | 5 |
| 11 | Query Mug | 12.99 | gifts | 33 |
BEGIN;UPDATE productsSET price = price * 1.1WHERE category = 'books';SELECT COUNT(*)FROM productsWHERE category = 'books';PostgreSQL is the lesson baseline unless noted otherwise.
Open a transaction so changes can be checked and committed or rolled back together.
COMMIT;PostgreSQL is the lesson baseline unless noted otherwise.
Read this line together with the surrounding statement as part of the same SQL expression.
ROLLBACK;PostgreSQL is the lesson baseline unless noted otherwise.
Read this line together with the surrounding statement as part of the same SQL expression.
Representative transaction status
Note: Assumes three book products matched. The final command is COMMIT only if the checked count is correct; use ROLLBACK instead to discard the update.
and then
if the count looks right, or
if it doesn't.
Key takeaway: Any GUI works; wrap risky changes in a transaction and mark production clearly.
How it works, step by step
Follow one practical SQL workflow from start to finish. Select any step or play through the flow.
Start a server
Run PostgreSQL or MySQL in Docker, or install it natively, with a password you set.
docker run … -p 5432:5432 postgres:18
When to use it & trade-offs
What it is
To practise SQL you need two things: a database server running somewhere (PostgreSQL or MySQL on your laptop, often in Docker) and a client to talk to it, either the command-line tools psql and mysql or a GUI such as DBeaver, pgAdmin or MySQL Workbench. The client connects with a host, port, database name, user and password, often written as one connection string like postgresql://app_user@localhost:5432/shop.
Why it matters: Reading about SQL only gets you so far; interview take-homes and real jobs expect you to load data, explore tables and run queries yourself. A clean local setup also teaches habits that matter at work: knowing which server you're connected to, using a separate user per purpose, and not running experiments against production.
When to reach for it
- Practising for SQL interviews and take-homes
- Testing a query before running it on a shared database
- Learning a second engine's dialect
When to avoid or be careful
- Practising on a production database
- Using the superuser account for everyday queries
- Running UPDATE or DELETE in autocommit mode without checking first
Ways to get a database to practise on
Strengths: One command to start, stop or reset; easy to run PostgreSQL and MySQL side by side.
Watch out: Needs Docker installed; data lives in volumes you must manage.
Strengths: Runs as a normal service; integrates with the OS.
Watch out: Harder to remove cleanly or run several versions.
Strengths: Nothing to set up.
Watch out: Limited data size and features; not your own environment.
Interview signals & numbers to know
When this topic comes up
- “Set up a local database for this take-home”
- “Which client do you use?”
- “Connect to the database at this host”
- Connection strings
- Working safely with production
Benchmarks & rules of thumb
- 5432
- PostgreSQL's default port
- 3306
- MySQL's default port
- 1 command
- to start a server in Docker
Common mistakes & follow-ups
Common interview mistakes
- Starting a second PostgreSQL on port 5432 while another is running, and connecting to the wrong one.
- Running a DELETE in a GUI with autocommit on, expecting to undo it.
- Leaving the Docker container without a volume, so the data disappears when the container is removed.
Likely interviewer follow-ups
- How would you set up PostgreSQL locally for a take-home assignment?
- What details does a client need to connect to a database?
- How do you avoid accidentally changing production data from a GUI?
Knowledge check
Put it into practice
Practice related interview Q&A
Apply Installing PostgreSQL / MySQL & Database Clients (DBeaver, pgAdmin) with hands-on SQL practice and interview Q&A.