Install PostgreSQL and DBeaver step-by-step. So clear, so detailed, your pet goldfish could follow along. Let's get your database running!
Think of it like a car. You need two things:
1. The Engine = PostgreSQL โ This is the actual database. It stores your data, runs your queries, and does all the heavy lifting. But you can't see it โ it runs in the background like a service.
2. The Steering Wheel + Dashboard = DBeaver โ This is a visual tool that lets you see your databases, tables, and data in a friendly window. You type SQL here, click buttons, browse data โ it's your control panel.
You COULD drive a car using only the engine (using the command line tool called psql), but having a dashboard makes everything easier, especially when learning!
There are many database tools: pgAdmin, DataGrip, TablePlus, Postico. We chose DBeaver because:
Choose your operating system below. Each set of instructions is complete โ follow every step and you'll be running in 10 minutes.
Go to postgresql.org/download/windows and click "Download the installer". This takes you to EnterpriseDB's download page. Choose the latest version (16.x) for Windows x86-64.
Double-click the downloaded .exe file. If Windows asks "Do you want to allow this app to make changes?", click Yes.
Keep all four checked: PostgreSQL Server, pgAdmin 4, Stack Builder, Command Line Tools. Click Next.
Leave the default (C:\Program Files\PostgreSQL\16\data). This is where your actual database files will live. Click Next.
This is the password for the postgres superuser โ the admin account. Write it down! You'll need it every time you connect. Use something simple for learning (like postgres123) โ you can change it later.
Default is 5432. Don't change it unless another PostgreSQL instance is already using this port. Click Next.
Click through the remaining screens and wait for installation to complete. Uncheck "Launch Stack Builder" at the end โ you don't need it right now.
Open Command Prompt (press Win + R, type cmd, hit Enter) and run:
-- Check PostgreSQL version psql --version -- Expected output: psql (PostgreSQL) 16.x
This means PostgreSQL's bin folder isn't in your PATH. Fix: Search "Environment Variables" in Windows, edit the Path variable, and add: C:\Program Files\PostgreSQL\16\bin. Restart Command Prompt and try again.
The easiest way on Mac is using Homebrew (a package manager). If you don't have Homebrew, install it first:
# Install Homebrew (if you don't have it) /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" # Install PostgreSQL brew install postgresql@16 # Start the PostgreSQL service brew services start postgresql@16 # Verify it's running psql --version psql (PostgreSQL) 16.x
After installing with Homebrew, PostgreSQL automatically creates a superuser with your Mac username (no password needed for local connections). You can connect instantly with: psql postgres
If you prefer a visual approach, download Postgres.app โ it's a one-click PostgreSQL installer for Mac. Just drag it to your Applications folder, open it, and click "Initialize." Done!
# Update package list sudo apt update # Install PostgreSQL and utilities sudo apt install postgresql postgresql-contrib # Check it's running sudo systemctl status postgresql โ postgresql.service - PostgreSQL RDBMS Active: active (exited) # Switch to the postgres user and test sudo -u postgres psql postgres=# SELECT version(); -- Shows: PostgreSQL 16.x on x86_64-pc-linux-gnu postgres=# \q
On Linux, the default postgres user has no password. Let's set one so DBeaver can connect:
sudo -u postgres psql ALTER USER postgres PASSWORD 'postgres123'; \q
DBeaver is like the "Finder" (Mac) or "File Explorer" (Windows) for databases. Instead of browsing folders and files, you browse databases, tables, and rows. It has a nice window where you can write SQL, see results, and explore your data visually.
Go to dbeaver.io/download and download the Community Edition (it's free) for your operating system:
.exe installer.dmg file (or use brew install --cask dbeaver-community).deb package (or use sudo snap install dbeaver-ce)Windows: Run the .exe, click Next through the wizard, leave defaults.
Mac: Open the .dmg, drag DBeaver to Applications.
Linux: sudo dpkg -i dbeaver-ce_*.deb or use Snap.
Launch DBeaver. On first run, it might ask to download a sample database โ you can skip this. You'll also see a "Tip of the Day" โ close that too.
When DBeaver opens, you'll see:
Think of it like a code editor (VS Code), but specialized for databases.
Right now, PostgreSQL is running on your computer like a chef in a kitchen. DBeaver is the dining room where you sit. We need to open the door between them so you can send orders (SQL queries) to the chef and get food (data) back. That "door" is called a connection.
In DBeaver, click the plug icon (๐) in the top-left toolbar, OR go to Database โ New Database Connection.
In the dialog that appears, you'll see a list of database types. Click PostgreSQL (the elephant icon ๐), then click Next.
Fill in these fields:
| Field | Value | Why |
|---|---|---|
| Host | localhost | PostgreSQL is on YOUR computer |
| Port | 5432 | Default PostgreSQL port |
| Database | postgres | Default database that always exists |
| Username | postgres | Default superuser account |
| Password | The one you set during installation | Authentication |
Click "Test Connection" at the bottom. If it says "Connected" with a green checkmark โ you're in! Click Finish.
net start postgresql-x64-16
brew services start postgresql@16
sudo systemctl start postgresql
ALTER USER postgres PASSWORD 'newpass';In the connection dialog, check "Save password locally" so you don't have to type it every time. For a learning environment, this is perfectly fine.
You're connected to PostgreSQL โ the kitchen is open! Right now there's a default database called postgres, but it's like the chef's break room. Let's create our OWN database โ our own restaurant โ and run our very first query!
In DBeaver, click on your PostgreSQL connection in the left panel to expand it. Then open a new SQL editor: SQL Editor โ New SQL Script (or press Ctrl+] / Cmd+]). Type:
-- Create your very first database! CREATE DATABASE my_first_db;
Press Ctrl+Enter (or Cmd+Enter on Mac) to execute. You should see a success message at the bottom. ๐
You just created a brand new, empty database on your computer. It's like creating a new, empty folder in your file system โ but this folder is designed to hold tables of data. Right-click your connection in the left panel and click "Refresh" to see my_first_db appear in the list!
DBeaver is still connected to the postgres database. To switch:
my_first_db)-- Your first ever SQL query! SELECT 'Hello, PostgreSQL! ๐' AS greeting;
Press Ctrl+Enter. You should see:
| greeting |
|---|
| Hello, PostgreSQL! ๐ |
Congratulations! You just talked to a database! ๐ฅณ That SELECT statement is SQL โ the language databases understand. You'll master it in the next modules.
-- Create a table for your favorite movies CREATE TABLE movies ( id SERIAL PRIMARY KEY, title VARCHAR(200) NOT NULL, year INTEGER, rating DECIMAL(2,1) ); -- Add some movies INSERT INTO movies (title, year, rating) VALUES ('The Shawshank Redemption', 1994, 9.3), ('The Dark Knight', 2008, 9.0), ('3 Idiots', 2009, 8.4), ('Inception', 2010, 8.8), ('Dangal', 2016, 8.3); -- See all your movies! SELECT * FROM movies;
Result:
| id | title | year | rating |
|---|---|---|---|
| 1 | The Shawshank Redemption | 1994 | 9.3 |
| 2 | The Dark Knight | 2008 | 9.0 |
| 3 | 3 Idiots | 2009 | 8.4 |
| 4 | Inception | 2010 | 8.8 |
| 5 | Dangal | 2016 | 8.3 |
CREATE TABLE = We built a filing cabinet called "movies" with 4 columns.
INSERT INTO = We put 5 movie records into that cabinet.
SELECT * FROM = We asked "Show me everything in the movies cabinet!"
That's it! You're already doing real database work. The next 11 modules will make you a master. ๐
-- Find movies with rating above 8.5 SELECT title, rating FROM movies WHERE rating > 8.5 ORDER BY rating DESC;
| title | rating |
|---|---|
| The Shawshank Redemption | 9.3 |
| The Dark Knight | 9.0 |
| Inception | 8.8 |
| Action | Windows | Mac |
|---|---|---|
| Execute statement | Ctrl + Enter | Cmd + Enter |
| Execute entire script | Ctrl + Shift + Enter | Cmd + Shift + Enter |
| New SQL script | Ctrl + ] | Cmd + ] |
| Auto-complete | Ctrl + Space | Ctrl + Space |
| Format SQL | Ctrl + Shift + F | Cmd + Shift + F |
DBeaver is great for visual work, but every PostgreSQL pro also knows psql โ the command-line interface. It's like texting vs calling โ sometimes the quick text (psql) is faster than opening the app (DBeaver).
# Connect to your database psql -U postgres -d my_first_db # You'll see the prompt: my_first_db=# # Run a query SELECT * FROM movies; # Useful psql commands (backslash commands): \l -- List all databases \dt -- List all tables in current database \d movies -- Describe the 'movies' table structure \c other_db -- Switch to another database \q -- Quit psql
| Use psql When... | Use DBeaver When... |
|---|---|
| Quick one-line queries | Exploring data visually |
| Server administration via SSH | Writing multi-line queries |
| Running scripts from files | Viewing table structures |
| You want to feel like a hacker ๐ | You want a nice GUI |
SELECT * FROM movies; do?You now have a fully working PostgreSQL setup! Here's what you accomplished:
You've already done a tiny taste of CREATE, INSERT, and SELECT. In the next module, we'll go DEEP into all the CRUD operations โ CREATE, INSERT, SELECT, UPDATE, DELETE โ with tons of examples, exercises, and quizzes. Get excited! ๐ฅ