Change the default PostgreSQL data directory on Windows

pgsql logoOur database which is storing every minute telemetry data is now getting bigger and need to be relocated to another newly mounted drive. So, I need to relocate the old data to a new disk. Actually, I don’t need to do this if my drive is a dynamic drive.

As we already know, PostgresSQL for Windows installs the PGDATA directory by default into “C:\Program Files\PostgreSQL\8.3\data”. This mini-HOWTO explains how to change the default PGDATA directory to another location. Note that 8.3 is the version number of my current PostgreSQL installation. It could be varied based on your installed version.

Step 1: Stop The PostgreSQL Service
Close all applications that are currently connected to your database, then go to Windows Services Management and stop the PostgreSQL service:

Start->Settings->Control Panel->Administrative Tools->Services

You should check the task manager to see if any postgresql.exe instances are still running. If so, DO NOT TERMINATE them, instead close all applications that are still connected to the database. Sometimes services like webservers keep persistent connections. In this case you also should stop these services.

Step 2: Change Registry Values

Start the Windows Registry Editor (regedit.exe) and navigate to: “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\pgsql-8.3”
. Double click on “ImagePath” and change the diectory after the “-D” option to your new location. If the path to your new location contains spaces, you should then enclose it with quotes.

Registry Editor

Step 3: Move the data folder to the new location

Move your current PGDATA directory to the directory you just specified in Step 2.
Please note that you should do this as Administrator on server machines.

Step 4: Restart The PostgreSQL Service

Before you can start your database you must close and re-open the Windows
Services Management window. This refreshes the path you just changed in the registry without the need to restart your system.

After closing and re-opening the Services Management window, you should check the “path to executable” information of the PostgreSQL Database service. The path after “-D” option should be pointing to your new directory now.

Service properties

Now that the PGDATA directory has been re-located and the service startup parameter in the registry has been modified. The new directory should be granted permissions to PostgreSQL service to access it.

Directory Properties Dialog

Add username which PostgreSQL service use.

And then, set some required permissions PostgreSQL operations.

Now, you can go ahead and start the service.



Tags: , , , , , ,

105 Responses to “Change the default PostgreSQL data directory on Windows”

  1. great post,however i have some difficulty in understanding the final paragraph, can you please describe a bit more?

  2. Cialis says:

    gzuGgp Excellent article, I will take note. Many thanks for the story!

  3. Awesome Post. I add this Blog to my bookmarks.

  4. Many Grodin says:

    Hi There! I ran into your site absolutely by mistake, and it turned out to being a blessing. You bring a lot of interesting things to the table and I will be back for more 🙂 Thanks!

  5. Thanks For This Blog, was added to my bookmarks.

  6. Intimately, the post is actually the best topic on this related issue. I fit in with your conclusions and will eagerly look forward to your approaching updates. Just saying thanks will not just be sufficient, for the phenomenal clarity in your writing. I will immediately grab your rss feed to stay abreast of any updates.

  7. You certainly deserve a round of applause for your post and more specifically, your blog in general. Very high quality material

  8. lapel pins says:

    Great info, thank you for making this available on your blog.

  9. scuba diving says:

    You certainly deserve a round of applause for your post and more specifically, your blog in general. Very high quality material

  10. Ron Cannell says:

    For some reason only half of the submit is being displayed, is it my browser or the website?

  11. I just visited your site through Facebook… would you be interested in getting weblog partners?

  12. I just visited your website via Facebook… would you be interested in getting weblog partners?

  13. Madlen says:

    Hi Webmaster, If you’re interested in making money from your blog and driving thousands of free visitors to your website then i will show you a secret way to build a Blog Empire that earned over $1,107,693! Just check it out now: http://tinyurl.com/new-blogging-system

  14. vemmaap says:

    I find myself coming to your blog more and more often to the point where my visits are almost daily now!

  15. vemmagg says:

    I just sent this post to a bunch of my friends as I agree with most of what you’re saying here and the way you’ve presented it is awesome.

  16. I’ve been visiting your blog for a while now and I always find a gem in your new posts. Thanks for sharing.

  17. scuba diving says:

    You certainly have some agreeable opinions and views. Your blog provides a fresh look at the subject.

  18. gry says:

    Awesome Post. I add this Post to my bookmarks.

  19. Hi administrator I wallow in w/ ur article . may i copy this know-how for my academic check ? thanks

  20. Hi administrator I rejoice in w/ ur content . can i copy this knowledge being my college test ? thanks

  21. Hello admin , i want how to ask question about A New content. is this okay ?(1st)Whats the meaning for which content? but i enjoy using Your New url. (2nd) are you have facebook or twitter > end users may add A New facebook badge just so i can like Your web site. like my blog Thank end usersbest Regards admin as for (sorry,if my english is bad. iam an italian :p)

  22. Hello dude,i like Your site ideal much. attain u have on suggestion being my site? thanks being Your attention

  23. Hello dude,i likes Your website very a lot. do u have on suggestion as my homepage? thanks as A New attention

  24. Hello dude,i like this Your blog very a lot. achieve u have suggestion for my site? thanks for Your New attention

  25. noni says:

    Awesome Blog. I add this Blog to my bookmarks.

  26. kosmetyki says:

    You certainly have some agreeable opinions and views. Your blog provides a fresh look at the subject.

  27. noni says:

    You certainly have some agreeable opinions and views. Your blog provides a fresh look at the subject.

  28. noni says:

    Very informative post. Thanks for taking the time to share your view with us.

  29. canon lenses says:

    You certainly deserve a round of applause for your post and more specifically, your blog in general. Very high quality material

  30. tapety says:

    You certainly have some agreeable opinions and views. Your blog provides a fresh look at the subject.

  31. noni says:

    Thanks For This Post, was added to my bookmarks.

  32. sok noni says:

    I find myself coming to your blog more and more often to the point where my visits are almost daily now!

  33. Hello dude,i like Your blog ideal much. achieve u have on suggestion for my website? thanks for Ones New attention

  34. Hello dude,i like Your site ideal a lot. accomplish u have suggestion for my homepage? thanks being A New attention

  35. Min Korst says:

    Hello dude,i liking Ones homepage in truth a lot. do u have suggestion as my site? thanks being A New attention

  36. Hey,

    I wanted to say that I have been watching for a while and I would like to sign up for the feed. I’ll give it a try but I might need some assistance. This is a great find and I would hate to lose touch, and maybe never find it again.

    Anyway, thanks again and I look forward to posting again sometime!

  37. Hello dude,i like Your site very much. accomplish u allow suggestion as my website? thanks for A New attention

  38. Hyun Solis says:

    Hello dude,i liking A New homepage ideal a lot. attain u allow suggestion being my site? thanks as Ones New attention

  39. Erwin Blatti says:

    Good infomation here, thanks.

  40. Weight loss says:

    I found your page via google thanks for the post. I will bookmark it for future reference.

  41. Alan Bernson says:

    Good night dude, i like your news ! Have a nice weekend

  42. mark says:

    What exactly did you mean in the second sentance?

  43. You are the man ! Nice article

  44. I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post

  45. Im sixteen am I able to use this product safely?

  46. Thanks for this usefull information.

  47. Tosha Kane says:

    excellent luck as end users

  48. You are the man ! Nice article

  49. Examples of these are extraordinary articles and reviews. Keep up all the warm handiwork.

  50. Following reading this posting, I pondered the exact same point that I invariably wonder about when scanning new blogs and forums. Just what do I believe about this? Precisely how need to it impact me? This and additional posts on your weblog right here absolutely give some stuff to think about. I basically ended up right here by way of Yahoo when I was initial doing some internet study for some course operate that I’ve. Usually great times browsing by way of and I’m hopeful that you’ll maintain on writing new posts. Cheers!

  51. Surprisee Dude , i like w/ Your article. LOL Please come to my blog

  52. Hallo Admin , i love w/ Your posting. LOL Please come to my blog

  53. hey Admin , i like with u posting. LOL Please come to my blog

  54. Surprisee adminstrator , i like with Your article.

  55. ha, I will test my thought, your post give me some good ideas, it’s really awesome, thanks.

    – Norman

  56. Will i repost this on my own blog site? I’ll try to drop you a link. Let me know, thanks!

  57. Adam Roal says:

    I’m having trouble looking at your blog in Opera, it keeps showing up errors.

  58. seo elite says:

    It’s constantly nice to see your weblog on here. I in reality enjoy your site .

  59. Glynis says:

    Love takes up where knowledge leaves off.

  60. seo says:

    Hi, You have a Great Blog, I found your blog on google and read a few of your other posts. I just added you to my Google News Reader. Keep it up.

  61. Good morning sir. How are you ? I like your post very much . Have a nice day .LOL bad introduction :p

  62. I love to read articles from blogs are more scattered. Through multiple touch of a finger we can find what we seek. And I most liked the article about the technology.

  63. money quotes says:

    Hay adminstrator . Why dont you add facebook badge on your blog ? Thanks Good luck

  64. Hay admin . Who is your writer sir ? good article

  65. Praca says:

    Your articles are very inspiring indeed. I keep coming back! There are so many things I agree on. I hope we can exhange ideas in the future.

  66. Telefony says:

    The well written summary assited me very much! Bookmarked your website, very excellent categories everywhere that I see here! I really appreciate the info, thanks.

  67. Banki says:

    SOrry for my english not so well, but me think that you are write too pointe.

  68. Please visit my site dude . Thank you sir

  69. Low Prices says:

    Hey, found your site by accident doing a search on Google but I?ll definitely be coming back. ? How can I believe in God when only last week I got my tongue caught in the roller of an electric typewriter?

  70. I to thank you for this good post .I definitely liked every little bit of it. I have you bookmarked your web site to look at the latest stuff you post.

  71. Hoffstetter says:

    Hi there may I use some of the information here in this post if I provide a link back to you website?Thank you.

  72. Bee Maglott says:

    @above me .lol Do you have another idea about my comment

  73. Great story sir.i will bookmark your blog

  74. Lona Longan says:

    Great story sir.i will bookmark your blog

  75. I love to comment on your blog sir

  76. Edison Salte says:

    @above me .lol Do you have another idea about my comment

  77. Kenny Rebman says:

    Do you have twitter account sir ? So i can follow your blog

  78. Hi… My name is Larry Khoo and I am an ESL teacher living in Kuala Lumpur. I’d like to be direct. I am building inbound links to my English essays teaching site and I would be glad if you could accept my backlink here. My resource is a 100 percent free site which assists learners on the methods of writing essays and I am certain that ESL students will reap some benefits from it. Once more, I hope you will not delete my thread, and I thank you in anticipation.

  79. Lipson says:

    Resources like the one you mentioned here will be very useful to me! I will post a link to this page on my blog. I am sure my visitors will find that very useful.

  80. Gathje says:

    This is one of the most genuine blog i had ever seen. Thanx for the info, i find it through google. Keep up the good work admin.

  81. shop online says:

    For example online shopping online chat online news are not a rare things. These product search engines are specially designed for product search millions of products are already in their database within seconds you can see a list of product and there are special tools designed to help online shopping.

  82. Great story sir.i will bookmark your blog

  83. Arroyo says:

    This is definitely an amazing blog. I located it while I was attempting to fix another problem. Your website is absolutely worthy of the bookmark and i’m sure it’ll come in handy in the future.

  84. Rutland says:

    Another informative post! Thanks!

  85. Odea says:

    Great job. I really like your posts

  86. Since gibing for some time for just a proper read in considers to this sort of niche . Attempting in Bing I now spotted this web site . Look this info So i am pleased to convey that I have a very good imprint I bumbled onto whatever I was ready for. I’ll make sure to don’t forget this site and consecrate it a look consistently .

  87. Please visit my site and you will know about situs informasi internet yang sesungguhnya didunia ini

  88. Hockman says:

    Very informative post! Thanks!

  89. Abolt says:

    Great blog. Will come again. 🙂

  90. awesome blog…

    Very awesome blog !! I couldnt have wrote this any better than you if I tried super hard hehe!! I like your style too!! it’s very unique & refreshing…

  91. facebook123 says:

    Superb website…

    […]always a big fan of linking to bloggers that I love but don’t get a lot of link love from[…]……

  92. car insurance comparison…

    Once you look at the internet to have an on the internet insurance estimate, you have a fantastic chance to find inexpensive along with necessary coverage regarding whichever the insurance requires might be….

  93. Get your horse tack!…

    Not sure if this is the right place (I’m not really good with computers), but left you a trackback for your readers, if they ever need some information about horse tack….

  94. Trackback for a Great Article…

    Left you a trackback for your readers to get more info….

  95. Informative and precise…

    Its hard to find informative and precise info but here I noted…

  96. Tumblr article…

    I saw a writer talking about this on Tumblr and it linked to…

  97. Just Browsing…

    While I was browsing today I noticed a excellent post concerning…

  98. Hi…

    Rattling nice design and good content, nothing else we want :D….

Leave a Reply