Skip to main content
0 reactions

PostgreSQL Tutorial — Part 3: pgAdmin 4 for Beginners

Featured card for PostgreSQL Tutorial Part 3, pgAdmin 4 for Beginners, with a checklist: pgAdmin 4 9.19, found PostgreSQL 19, Object Explorer, and SELECT version();.
PostgreSQL Tutorial Part 3: pgAdmin 4 for Beginners

psql is quick, but some things are easier to see than to type. pgAdmin 4 is PostgreSQL’s free graphical tool: a window where you browse your servers and databases in a tree, and type SQL in an editor that shows the results in a grid.

In this part you open pgAdmin, connect it to your PostgreSQL 19 server, find your way around its main window and run your first query in the Query Tool. By the end, pgAdmin is ready for every later part that uses it.

This is Part 3 of the PostgreSQL Tutorial. The parts in Module A, Start Here:

All parts of the PostgreSQL Tutorial

Module A: Start Here

Module B: Build the Database

  • Part 4: Create a Database
  • Part 5: Data Types Explained
  • Part 6: Create Tables
  • Part 7: Primary Keys, Foreign Keys and Constraints
  • Part 8: Insert, Update and Delete Data
  • Part 9: Import and Export CSV Files

Module C: Query Data

  • Part 10: SELECT, WHERE, ORDER BY and LIMIT
  • Part 11: LIKE, IN, BETWEEN, NULL and CASE
  • Part 12: GROUP BY and Aggregate Functions
  • Part 13: JOINs Explained
  • Part 14: Subqueries and CTEs
  • Part 15: UNION, INTERSECT and EXCEPT
  • Part 16: String, Number and Conversion Functions
  • Part 17: Dates, Times and Time Zones

Module D: Design and Performance

  • Part 18: Database Design and Normalization
  • Part 19: Views and Materialized Views
  • Part 20: Indexes Explained
  • Part 21: EXPLAIN and Query Performance
  • Part 22: Transactions, Isolation Levels and Locks

Module E: Advanced SQL and Programming

  • Part 23: Window Functions
  • Part 24: Recursive Queries and LATERAL Joins
  • Part 25: JSON and JSONB
  • Part 26: Arrays, Enums, Ranges and Generated Columns
  • Part 27: Full-Text Search
  • Part 28: Functions and Stored Procedures
  • Part 29: Triggers

Module F: Administration and Security

  • Part 30: Users, Roles and Privileges
  • Part 31: Row-Level Security
  • Part 32: Configuration and Restarting the Server
  • Part 33: Allow Remote Connections Securely
  • Part 34: Backup and Restore
  • Part 35: Automate Backups
  • Part 36: VACUUM, ANALYZE and Autovacuum
  • Part 37: Monitoring and Slow Queries
  • Part 38: Table Partitioning
  • Part 39: Streaming Replication
  • Part 40: Upgrade to a New Major Version

Module G: PostgreSQL for Developers

  • Part 41: Connect from C# .NET with Npgsql
  • Part 42: Entity Framework Core with PostgreSQL
  • Part 43: Connect from Python with psycopg
  • Part 44: Connect from Node.js with node-postgres

Module H: Extensions, AI and Cloud

  • Part 45: Extensions
  • Part 46: Vector Search with pgvector
  • Part 47: Azure Database for PostgreSQL
  • Part 48: Migrate to Azure and What to Learn Next

Every screen and output on this page is real, from pgAdmin 4 9.19 with PostgreSQL 19 on macOS.

Where the bookstore database is now: it doesn’t exist yet. Part 4 creates it, so there’s nothing to catch up on. In this part you only look around the server.

Prerequisites

Step 1: Open pgAdmin 4

Open pgAdmin 4 from your Applications folder. If you installed PostgreSQL as How to Install PostgreSQL 19 on macOS shows, it’s already there. The window opens on the Welcome page:

The pgAdmin 4 window on its first launch, with the Object Explorer on the left and the Welcome page with Quick Links and Getting Started on the right.
pgAdmin 4 on its first launch.
  • Object Explorer, on the left: a tree of your servers and everything in them.
  • Tabs, on the right: Dashboard, Properties, SQL and more, each showing something about whatever you select in the tree.
  • Welcome: links to get started, such as Add New Server.

Step 2: Connect to Your Server

Click the arrow next to Servers. pgAdmin already lists PostgreSQL 19: it looks for PostgreSQL servers installed on your computer and adds them by itself, as its configuration documentation (opens in a new tab) describes. The red cross on the icon means pgAdmin isn’t connected yet.

The Object Explorer with Servers opened, showing PostgreSQL 19 with a small red cross on its icon because it is not connected yet.
pgAdmin already lists the PostgreSQL 19 server.

Double-click PostgreSQL 19. pgAdmin asks for the password of the postgres user:

The Connect to Server box asking for the password of the user postgres for the server PostgreSQL 19, with a Save Password tick box and Cancel and OK buttons.
Type the postgres password, then click OK.

Type the password you chose when you installed PostgreSQL, the same one psql asks for. Tick Save Password so pgAdmin doesn’t ask again, then click OK.

Note: The desktop version of pgAdmin keeps saved passwords in your computer’s own password store, so it doesn’t ask you for a master password, as the pgAdmin documentation (opens in a new tab) explains.

pgAdmin connects. The red cross disappears, the server opens to show Databases, Login/Group Roles and Tablespaces, and the Dashboard tab shows live graphs of what the server is doing:

PostgreSQL 19 connected in the Object Explorer, with Databases, Login/Group Roles and Tablespaces under it, and the Dashboard showing graphs of server sessions, transactions and tuples.
Connected: the server opens and the Dashboard shows live graphs.

Step 3: Find Your Way Around the Object Explorer

Double-click Databases, then postgres, then Schemas, then public:

The Object Explorer opened down through PostgreSQL 19, Databases, postgres, Schemas and public, which lists Tables, Views, Functions and other kinds of objects.
The Object Explorer opened down to the public schema.
  • Databases: every database on the server. postgres is the default one, which you connected to with psql in Part 2.
  • Schemas › public: a schema (opens in a new tab) holds tables and other objects, and every new database starts with one named public. Its Tables folder is empty for now: Part 4 creates a database of your own, and later parts add tables to it.
  • Login/Group Roles: the roles (opens in a new tab), PostgreSQL’s name for users and groups of users, such as postgres.
  • Tablespaces: places on disk (opens in a new tab) where PostgreSQL can keep its files. You can leave them alone.

Step 4: Open the Query Tool

Click postgres to select the database, then click the Query Tool button: the second icon in the toolbar above the tree, a database with a small arrow. A new tab opens:

A new Query Tool tab named postgres/postgres@PostgreSQL 19, with an empty SQL editor, a Scratch Pad on the right and the Data Output, Messages and Notifications tabs below.
A new Query Tool, connected to the postgres database.

The tab’s name, postgres/postgres@PostgreSQL 19, shows the database, the user and the server the Query Tool is connected to. You type SQL in the editor at the top, and results appear in Data Output below it.

Step 5: Run Your First Query

Type this in the editor:

Query ToolSQL
SELECT version();

Press F5, or click the Execute script button, the triangle in the toolbar. The result appears in Data Output:

The Query Tool with SELECT version(); in the editor and one row in Data Output that starts with PostgreSQL 19.0 on aarch64-apple-darwin.
SELECT version(); and its result in Data Output.

It’s the same answer psql gave you in Part 2: the version of the PostgreSQL server you’re connected to.

Common Mistakes

MistakeWhat happensDo this instead
Typing the wrong passwordpassword authentication failed for user "postgres"Type the password you chose when you installed PostgreSQL; it’s the same one psql asks for.
Clicking Add New Server when PostgreSQL 19 is already listedYou end up with two entries for the same server.Use the entry pgAdmin already lists, and remove the extra one, as How to Remove a Server from pgAdmin 4 shows.

Troubleshooting

ProblemLikely causeFix
PostgreSQL 19 isn’t listed under ServerspgAdmin found no PostgreSQL installation on this computer, for example because your server runs on another machine.Add it yourself, as How to Register a Server in pgAdmin 4 shows.
Connecting fails with Connection refusedThe server isn’t running, or it listens on a different port.Start PostgreSQL, and check the port: 5432 unless you changed it.

FAQ

Is pgAdmin part of PostgreSQL?

No. pgAdmin is a separate, free and open-source project with its own versions: this part uses pgAdmin 4 9.19 with PostgreSQL 19. The PostgreSQL installer for macOS offers to install it for you.

Can I use pgAdmin and psql at the same time?

Yes. Both are clients of the same server, as Part 1 explains, so you can keep both open and use whichever suits the job.

Conclusion

You opened pgAdmin, connected it to PostgreSQL 19, looked around the Object Explorer and ran your first query in the Query Tool. From now on, you can follow the SQL in every part in psql or in pgAdmin, whichever you prefer.

← Previous: Part 2: Connect with psql and Run Your First Commands

Next → Part 4: Create a Database: create the bookstore database that the rest of the tutorial builds on, and connect to it.

Additional Resources

Postgres, PostgreSQL and the Slonik Logo are trademarks or registered trademarks of the PostgreSQL Community Association of Canada, and used with their permission.

0 comments