How to Set Up pgAdmin 4 for PostgreSQL: A Step-by-Step Beginner Guide

PostgreSQL is one of the most popular databases in the world, and pgAdmin 4 is the free tool most people use to interact with it visually. If you have never set either of them up before, this guide walks you through every step - from download to running your first query.

What You Will Need

  • A Windows, Mac, or Linux computer
  • An internet connection for the downloads
  • About 15 minutes

Step 1 - Download and Install PostgreSQL

Go to the official PostgreSQL download page at postgresql.org/download and choose your operating system. The installer includes everything: the database server, command-line tools, and an option to install pgAdmin 4 at the same time.

During installation you will be asked to:

  • Choose an installation directory (the default is fine).
  • Select components - keep all of them ticked, including pgAdmin 4 and Stack Builder.
  • Choose a data directory where your databases will be stored.
  • Set a password for the superuser account called postgres. Write this down - you will need it.
  • Choose a port - leave it as 5432 (the default).

Click through and let the installation finish. On Windows this takes a few minutes.

Step 2 - Open pgAdmin 4

Once PostgreSQL is installed, search for pgAdmin 4 in your applications and open it. The first time it opens, it will ask you to set a master password for pgAdmin itself (separate from your PostgreSQL password). Set something you will remember.

pgAdmin opens in your browser as a web interface - this is normal. It is a local application that happens to run in the browser.

Step 3 - Connect to Your PostgreSQL Server

In the left panel you will see a Servers section. Expand it and you should see a server listed. If prompted for a password, enter the postgres superuser password you set during installation.

If no server appears, right-click Servers and choose Register > Server. Fill in:

  • Name - anything you like, e.g. Local PostgreSQL
  • Host - localhost
  • Port - 5432
  • Username - postgres
  • Password - the one you set during installation

Click Save. The server should appear in the panel.

Step 4 - Create Your First Database

Expand your server in the left panel, then expand Databases. You will see a default database called postgres. To create your own:

  • Right-click Databases and choose Create > Database.
  • Give it a name, for example practice_db.
  • Leave all other settings as default and click Save.

Step 5 - Open the Query Tool and Run SQL

Select your new database in the left panel, then click the Query Tool icon at the top (or go to Tools > Query Tool). A text editor opens.

Try running this to confirm everything is working:

SELECT 'Hello, PostgreSQL!' AS message;

Press F5 or click the Run button. You should see your message appear in the results panel below. Congratulations - your PostgreSQL and pgAdmin 4 setup is working.

Step 6 - Create a Table and Insert Data

Now try something more realistic:

CREATE TABLE customers (
    customer_id   SERIAL PRIMARY KEY,
    full_name     VARCHAR(100),
    email         VARCHAR(150),
    signup_date   DATE
);

INSERT INTO customers (full_name, email, signup_date)
VALUES
    ('Alice Chen',   'alice@example.com',  '2024-01-10'),
    ('Marcus Brown', 'marcus@example.com', '2024-02-14'),
    ('Sara Okafor',  'sara@example.com',   '2024-03-05');

SELECT * FROM customers;

Run all three blocks in order (you can select them all and press F5). You will see your three rows appear in the results.

Step 7 - Import a CSV File into Your Table

Once you have a table created, you can load a CSV file into it without writing any code. Here is the exact path to follow.

Common mistake to avoid: Do NOT go to Tools > Import/Export Servers. That dialog only handles server configuration files in JSON format - it cannot import CSV data. Many beginners land on the wrong screen here.

The correct steps:

  1. In the left panel, expand your database, then Schemas > public > Tables.
  2. Right-click the table you want to import into and select Import/Export Data.
  3. A dialog opens with two tabs at the top: Import and Export. Make sure Import is selected.
  4. Click the folder icon next to Filename and browse to your CSV file.
  5. Set Format to csv.
  6. Toggle Header on if your CSV has a header row (it almost always does).
  7. Set Delimiter to , (comma).
  8. Click OK. pgAdmin will show a success message with the number of rows imported.

To confirm the data loaded, right-click your table and select View/Edit Data > All Rows.

Common Issues and Fixes

  • pgAdmin shows a connection error: Check that the PostgreSQL service is running. On Windows, open Services and look for postgresql-x64. On Mac/Linux, run: pg_ctl status
  • Wrong password: The postgres password is the one you set during installation, not your computer login.
  • Port 5432 already in use: Another PostgreSQL instance may be running. Stop it first or change the port to 5433.
  • pgAdmin is very slow to open: This is normal the first time - it is loading a local web server. Give it 20-30 seconds.

What to Do Next

Now that your environment is set up, you are ready to start writing real SQL. A good next step is practising SELECT queries, filtering with WHERE, and aggregating with GROUP BY. The best way to learn is to write queries on real data - not just read about it.

Try it yourself

Start with Level 1: SELECT, in your browser.

The first 5 levels are free · no sign-up needed