Installing PostgreSQL on Windows
By Ercan S. - 13/04/2025 - 0 comments
This guide outlines the steps to install and initialize PostgreSQL on a Windows environment using the ZIP archive.
1. Download PostgreSQL
Visit the official PostgreSQL website and download the ZIP archive:
https://www.enterprisedb.com/download-postgresql-binaries
2. Extract the ZIP File
Extract the downloaded ZIP file to your desired location, for example:
D:\Dev\pgsql-14.1
3. Create Necessary Directories
Within the extracted folder, create the following directories:
mkdir <<postgresql_path>>\data mkdir <<postgresql_path>>\log
4. Initialize PostgreSQL
Run the following command to initialize the database and create the `postgres` user:
.\initdb.exe -D "<<postgresql_path>>\data" -U postgres -W -E UTF8 -A scram-sha-256
5. Start PostgreSQL Server
To start the PostgreSQL server, execute:
.\pg_ctl.exe -D "<<postgresql_path>>\data" -l "<<postgresql_path>>\log\postgre.log" start
6. Stop PostgreSQL Server
To stop the server, use:
.\pg_ctl.exe -D "<<postgresql_path>>\data" -l "<<postgresql_path>>\log\postgre.log" stop
7. Restart PostgreSQL Server
To restart the server, run:
.\pg_ctl.exe -D "<<postgresql_path>>\data" -l "<<postgresql_path>>\log\postgre.log" restart
Tags: postgresql, windows