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.

Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

If you like this post, then please share it with others.
Please follow, I will share my experience towards the success of Database Research and Development Activity.

I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.

More from

Leave a Reply

Be the First to Comment!

Notify of