Skip to content

Instantly share code, notes, and snippets.

@deepanshumehtaa
Created October 31, 2025 08:50
Show Gist options
  • Select an option

  • Save deepanshumehtaa/b5a7a7e9b293254620ead19ab880fa72 to your computer and use it in GitHub Desktop.

Select an option

Save deepanshumehtaa/b5a7a7e9b293254620ead19ab880fa72 to your computer and use it in GitHub Desktop.
postgres on corporate windows
## set postgres data folder:
1. set env PGDATA = "C:/Development/psql_data"
2. RUN
go inside bin folder of postgres and RUN
initdb -D %PGDATA%
## create user
> createuser.exe -U <ROLE> --superuser --pwprompt <USERNAME>
> createuser.exe -U postgres --superuser --pwprompt deepanshu
{IF above is giving error, run psql in single user mode and crate user}
## RUN Postgres in single user mode
> "C:\Development\postgresql-17.6-2-x64-bin\pgsql\bin\postgres.exe" --single -D %PGDATA% postgres
> CREATE ROLE deepanshu WITH SUPERUSER LOGIN PASSWORD 'deepanshu';
## Run PostgreSQL:
1. WITH ADMIN privilege:
> pg_ctl register -N "postgresql-17" -U postgres -D "C:\Development\psql_data"
> pg_ctl register -N "postgresql-17" -U postgres -D %PGDATA%
2. without admin
> pg_ctl -D %PGDATA% start
## make connection, once server is running connect with username and password
> psql -U deepanshu -d postgres -h localhost
## make db
> create database mydb;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment