This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In this post, I am sharing basic steps to move or change the default Windows Data Directory of the PostgreSQL.
When we install PostgreSQL on Windows operating system, by default It store in “C:\Program Files\PostgreSQL\.\Data\”
Always best practice is to store database data in separate drive instead of the system drive.
Here, It is step-by-step:
Step 1:
Go to Windows Service, and Stop running PostgreSQL service.
To Close all your running transactions and applications which are currently connected to PostgreSQL.
Step 2:
If you are ready with your new location path, copy old data directory and paste in the new location path.
Step 3:
Right click on the newly created folder and make sure that It has all type permissions for local postgres system user.
Step 4:
Open Windows Registry Editor and go to this path “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\postgresql”.
Double click on “ImagePath” and change the default path of the Data Directory after “-D”
1 "C:\Program Files\PostgreSQL\9.5\bin\pg_ctl.exe" runservice -N "postgresql-x64-9.5" -D "D:\dbrnd\PostgreSQL\9.5\data" -w
Step 5:
Close all the open window and start the PostgreSQL Service.