Database Research & Development

  • Home
  • NoSQL
    • NoSQL
    • Cassandra
  • Databases
    • Database Theory
    • Database Designing
    • SQL Server Coding Standards
    • SQL Server
    • PostgreSQL
    • MySQL
    • Greenplum
    • Linux
  • Interviews
    • SQL Server Interviews
    • MySQL Interviews
    • SQL Puzzles
  • DBA Scripts
    • SQL Server DBA Scripts
    • PostgreSQL DBA Scripts
    • MySQL DBA Scripts
    • Greenplum DBA Scripts
  • Home
  • Blog Archives !
  • (: Laugh@dbrnd :)
  • Contact Me !
sqlserverinterviews
Home 2016 August PostgreSQL: Change or Move Default Data Directory in Windows

PostgreSQL: Change or Move Default Data Directory in Windows

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.

Aug 27, 2016Anvesh Patel
PostgreSQL: How to increase the performance of Bulk Insertion (INSERT)PostgreSQL 9.4: How to Convert JSON ARRAY Elements into String ARRAY
Comments: 4
  1. Alex
    September 12, 2017 at 1:10 am

    Anvesh,
    Thanks a lot for very informative port. I was trying to follow steps and run into problem. Hope you can help to clarify. I have PostgreSQL 9.5 on windows and image-path (in regedit) shows startup line as C:\PostgreSQL\pg95\pgservice.exe “//RS//PostgreSQL 9.5 Server” , so there is no explicit data-directory to change. How would you recommend to change data-directory in my setting?
    Thanks in advance.
    Alex

    • Anvesh Patel
      Anvesh Patel
      September 12, 2017 at 6:01 pm

      I am not sure, need to check. But may be you can make a new entry in regedit.

  2. Evgenii Lycenok
    August 16, 2018 at 5:42 am

    We successfully did it without any issues.

  3. Shani
    July 9, 2019 at 4:15 am

    Does this also restrict another local user from accessing the database that a particular user created in the data folder? If not then how can that be possible?

Anvesh Patel
Anvesh Patel

Database Engineer

August 27, 2016 PostgreSQLAnvesh Patel, data directory, database, database research and development, dbrnd, plpgsql, Postgres Query, postgresql, PostgreSQL Administrator, PostgreSQL Error, PostgreSQL Programming, PostgreSQL Tips and Tricks, windows operating system
About Me!

I'm Anvesh Patel, a Database Engineer certified by Oracle and IBM. I'm working as a Database Architect, Database Optimizer, Database Administrator, Database Developer. Providing the best articles and solutions for different problems in the best manner through my blogs is my passion. I have more than six years of experience with various RDBMS products like MSSQL Server, PostgreSQL, MySQL, Greenplum and currently learning and doing research on BIGData and NoSQL technology. -- Hyderabad, India.

About DBRND !

dbrnd

This is a personal blog (www.dbrnd.com).

Any views or opinions represented in this blog are personal and belong solely to the blog owner and do not represent those of people, institutions or organizations that the owner may or may not be associated with in professional or personal capacity, unless explicitly stated.

Feel free to challenge me, disagree with me, or tell me I’m completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever (abusive, profane, rude, or anonymous comments) - so keep it polite.

The content of this website is protected by copyright. No portion of this website may be copied or replicated in any form without the written consent of the website owner.

Recent Comments !
  • Anvesh Patel { Sure will do... } – May 27, 12:43 PM
  • Anvesh Patel { Great... } – May 27, 12:41 PM
  • Anvesh Patel { Great... } – May 27, 12:39 PM
  • Anvesh Patel { Great... } – May 27, 12:36 PM
  • Anvesh Patel { Great... } – May 27, 12:28 PM
  • Anvesh Patel { Great... } – May 27, 12:27 PM
  • Anvesh Patel { Great... } – May 27, 12:16 PM
  • Older »
Follow Me !
  • facebook
  • linkedin
  • twitter
  • youtube
  • google
  • flickr
© 2015 – 2019 All rights reserved. Database Research & Development (dbrnd.com)
Posting....