How to Download and Install PostgreSQL on Windows?

PostgreSQL is a powerful, open-source relational database system used for enterprise applications. This guide covers downloading, installing, configuring, and testing PostgreSQL on Windows.

Downloading PostgreSQL

  • Go to postgresql.org/download/windows
  • Click Download the installer (EnterpriseDB graphical installer)
  • Select the latest version for your OS (64-bit recommended)
  • Download will begin automatically

Installing PostgreSQL

Run the downloaded installer and follow these steps

  • Step 1: Welcome screen → Click Next
  • Step 2: Select components (keep all selected: PostgreSQL Server, pgAdmin, Command Line Tools, Stack Builder)
  • Step 3: Choose installation directory (default recommended)
  • Step 4: Choose data directory (default recommended)
  • Step 5: Set superuser password remember this password
  • Step 6: Port number default is 5432 (change only if needed)
  • Step 7: Advanced options leave defaults
  • Step 8: Review and click Next to install

Configuring PostgreSQL

Two key configuration files are located in the data directory (e.g., C:\Program Files\PostgreSQL\16\data\)

postgresql.conf

Controls server behavior. To allow remote connections ?

# Default (local only)
#listen_addresses = 'localhost'

# Allow all connections
listen_addresses = '*'

pg_hba.conf

Controls client authentication. To allow local trusted connections ?

# TYPE  DATABASE  USER  ADDRESS        METHOD
host    all       all   127.0.0.1/32   trust

Restart PostgreSQL after changing either file for changes to take effect.

Testing Your Installation

Open Command Prompt and run ?

psql -U postgres

If installed correctly, you should see ?

psql (16.x)
Type "help" for help.

postgres=#

Test with a basic query ?

SELECT version();
                          version
------------------------------------------------------------
 PostgreSQL 16.x on x86_64-pc-mingw64, compiled by ...
(1 row)

Conclusion

PostgreSQL installation on Windows involves downloading the graphical installer, running through the setup wizard (setting password, port, and data directory), then configuring postgresql.conf and pg_hba.conf for your environment. Test with psql to verify everything works correctly.

Updated on: 2026-03-14T22:55:33+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements