Created
August 8, 2022 14:03
-
-
Save yilmazdurmaz/3e2229fd2cf3cd5305b57f80c422d677 to your computer and use it in GitHub Desktop.
start/stop postgresql server in windows with a simple batch file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: postgresql is extracted into "d:\pgsql\" and data is init at "d:\pgsql\pgdata" | |
:: d:\pgsql\bin\initdb -D d:\pgsql\pgdata -U postgres -W -E UTF8 -A scram-sha-256 | |
:: find postres instances running on our data folder | |
wmic.exe path Win32_Process where name="postgres.exe" get Commandline /format:list | find "d:/pgsql/pgdata" > null | |
:: stop is already running, and start if not | |
if errorlevel 1 (d:\pgsql\bin\pg_ctl -D d:\pgsql\pgdata -l logfile start) else (d:\pgsql\bin\pg_ctl -D d:\pgsql\pgdata -l logfile stop) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment