Skip to content

Instantly share code, notes, and snippets.

@larschinkel
Created November 28, 2020 07:19
Show Gist options
  • Save larschinkel/b12a511d3172a080b90a727ed8d4937a to your computer and use it in GitHub Desktop.
Save larschinkel/b12a511d3172a080b90a727ed8d4937a to your computer and use it in GitHub Desktop.

PostgreSQL


Install


Download binaries from https://www.enterprisedb.com/download-postgresql-binaries, unzip them into a directory of your choice, add that path to environment variable & create the database using initdb found in the bin subdirectory:

> initdb -D {path} -U postgres -W -E UTF8 -A scram-sha-256
> initdb -D c:\local\var\data -U postgres -W -E UTF8 -A scram-sha-256

This will create the PostgreSQL data directory in the given path.

-U postgres creates the superuser as postgres
-W will prompt you for the password of the superuser
-E UTF8 will create the database with UTF-8 encoding
-A scram-sha-256 enables the password authentication

Start


> pg_ctl -D {path} -l {path} start
> pg_ctl -D c:\local\var\data -l c:\local\var\log\postgresql.log start

Stop


> pg_ctl -D {path} stop
> pg_ctl -D c:\local\var\data stop

Service


Register

> pg_ctl register -N PostgreSQL -D {path} 
> pg_ctl register -N PostgreSQL -D c:\local\var\data

Unregister

> pg_ctl unregister -N PostgreSQL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment