How to Install PostgreSQL 19 on Windows and Create Your First Database
- Details
- Written by Nam Ha Minh
- Last Updated on 01 December 2026   |   Print Email
SELECT *
FROM public.students
ORDER BY student_id;
Table of Content:
1. Download PostgreSQL for Windows
2. Install PostgreSQL Server
3. Install pgAdmin 4
4. Verify the PostgreSQL installation
5. Open pgAdmin and connect to the local PostgreSQL server
6. Create your first PostgreSQL database
7. Create a new table
8. Insert rows with the pgAdmin data editor
9. Disconnect from the server
10. Common installation problems
What the PostgreSQL installer provides
The Windows installer brings together the database server and the tools needed for local development. For a first installation, I recommend keeping the default components selected. They use little extra disk space and save you from returning to the installer when you need a command-line utility later.| Component | Purpose |
| PostgreSQL Server | Runs the database engine and stores the database cluster on disk. |
| pgAdmin 4 | Provides a graphical interface for connecting to servers and managing databases, schemas, tables, and data. |
| Command Line Tools | Includes utilities such as psql, pg_dump, pg_restore, and createdb. |
| Stack Builder | Downloads optional drivers, extensions, and supporting packages after the core installation. |
- Use a 64-bit version of Windows and sign in with an account that can install software.
- Choose a password for the postgres superuser and store it securely. pgAdmin needs it for the first connection.
- Keep TCP port 5432 unless another PostgreSQL instance already uses it.
- Allow roughly 1 GB of free disk space for the programs, then reserve additional space for database data and backups.
1. Download PostgreSQL for Windows
Open the PostgreSQL website: Go to the official PostgreSQL website and click Download on the home page:
Open PostgreSQL.org and select Download.
Choose Windows on the PostgreSQL download page
Continue to the Windows installer download
Download PostgreSQL 19 for Windows x86-64

Wait for the PostgreSQL installer download to finish
2. Install PostgreSQL Server
Launch the setup program: Open the downloaded executable. Approve the Windows security prompt if one appears, then click Next on the welcome screen.
Start the PostgreSQL setup wizard

Keep or change the PostgreSQL installation directory

Select the PostgreSQL components to install

Choose where PostgreSQL will store the database cluster

Set the password for the postgres superuser
Keep port 5432: PostgreSQL listens on TCP port 5432 by default. Keeping the standard port makes examples and development tools easier to configure. Change it only if the port is already in use or your environment requires a different value.
Use the default PostgreSQL port 5432

Select the locale for the database cluster

Review the PostgreSQL preinstallation summary

PostgreSQL installation in progress

The installer initializes the PostgreSQL database cluster
3. Install pgAdmin 4
pgAdmin is the graphical client used in the rest of this tutorial. Depending on the installer build, its setup may run as a separate wizard. Choose Yes when the PostgreSQL installer asks whether to install it.
Allow the installer to set up pgAdmin 4

The PostgreSQL setup starts the pgAdmin installer

Start the pgAdmin 4 setup wizard

Accept the pgAdmin license agreement

Choose the pgAdmin installation directory

Choose the pgAdmin Start menu folder

Confirm that pgAdmin is ready to install

pgAdmin installation in progress

Finish the pgAdmin setup wizard

The setup program creates the PostgreSQL uninstaller

Finish setup without launching Stack Builder
4. Verify the PostgreSQL installation
Before creating a database, verify that the PostgreSQL Windows service is running. A successful program installation is not enough; clients can connect only while the service is active.Check the service in Task Manager: Open Task Manager, select the Services tab, and find the PostgreSQL service. Its status should be Running.
Verify that the PostgreSQL service is running Open the Services console: Right-click the PostgreSQL service name (postgresql-x64-19) and choose Open Services. This opens the Windows Services management console, where you can inspect and control the service.

Open the PostgreSQL service in the Windows Services console

PostgreSQL Windows service properties
Get-Service -Name "postgresql*"
5. Open pgAdmin and connect to the local PostgreSQL server
Launch pgAdmin 4: Open the Start menu, type pgadmin, and select pgAdmin 4.
Launch pgAdmin 4 from the Windows Start menu
Wait for pgAdmin 4 to start

Enter the postgres superuser password

The connected PostgreSQL server in pgAdmin Object Explorer
6. Create your first PostgreSQL database
Open the Create Database dialog: Right-click Databases, point to Create, and choose Database.
Create a database from the Databases context menu

Create a database named schooldb

The schooldb database appears in Object Explorer
CREATE DATABASE schooldb;
A PostgreSQL server contains databases, and each database contains schemas. A schema is a namespace that groups tables and other objects. New databases normally include a public schema, so the fully qualified table name in this tutorial is public.students. Qualifying the schema makes SQL clearer and avoids surprises when an application changes its search path.7. Create a new table
Open the Create Table dialog: Expand schooldb, Schemas, public, and Tables. Right-click Tables, point to Create, and choose Table.
Create a table in the public schema

Name the new table students
| Column | Data type | Purpose |
| student_id | serial | Primary key whose value is generated from a sequence |
| name | character varying 50 | Student name with a maximum length of 50 characters |
| age | smallint | Small integer value for the student's age |
Define the students table columns and primary key

The students table in the public schema
CREATE TABLE public.students (
student_id serial PRIMARY KEY,
name varchar(50),
age smallint
);
CREATE TABLE public.students_identity_example (
student_id integer GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
name varchar(50),
age smallint
);
8. Insert rows with the pgAdmin data editor
Open all rows: Right-click public.students, point to View / Edit Data, and choose All Rows. pgAdmin opens a Query Tool tab and runs a SELECT statement for the table.
Open the pgAdmin data editor for the studentstable
The Query Tool and Data Output panes for public.students

Add John Doe and Mary Jones in the data editor

The saved students rows with generated primary keysSQL equivalent
INSERT INTO public.students (name, age)
VALUES
('John Doe', 23),
('Mary Jones', 30);
SELECT student_id, name, age
FROM public.students
ORDER BY student_id;
9. Disconnect from the server
Disconnecting pgAdmin closes its session; it does not stop the PostgreSQL Windows service. The server continues running in the background for other applications. Right-click the server, choose Disconnect from Server, confirm the action, and then close pgAdmin.
Disconnect pgAdmin from the PostgreSQL server
10. Common installation problems
Password rejected Confirm that you are entering the database password created during setup for the postgres role. It may differ from your Windows password. Connection refused on port 5432 Check that the PostgreSQL service is running and that pgAdmin uses the port selected during installation. If you installed more than one major version, each instance normally needs a different port. Database or table not visible Refresh the relevant Object Explorer node. Also confirm that you created the table under schooldb and the public schema rather than under the postgres maintenance database. Stack Builder was skipped That is fine for this tutorial. PostgreSQL Server, pgAdmin, and the command-line tools are already installed. Open Stack Builder later only when you need an optional driver or extension package.Where to go next
You now have a working local PostgreSQL environment and a small database that you can query. A useful next exercise is to open the Query Tool for schooldb, run the SQL examples from this article, and then practice UPDATE, DELETE, filtering with WHERE, and sorting with ORDER BY. Before using PostgreSQL for an important project, also learn how to create a non-superuser application role and how to back up a database with pg_dump.About the Author:
Nam Ha Minh is certified Java programmer (SCJP and SCWCD). He began programming with Java back in the days of Java 1.4 and has been passionate about it ever since. You can connect with him on Facebook and watch his Java videos on YouTube.