PostgreSQL: Change or Move Default Data Directory in Windows

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”

Step 5:

Close all the open window and start the PostgreSQL Service.

Anvesh Patel

Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz