2

Disclaimer: as this should be a standard operation, i feel something on my side must have gone terribly wrong.

I am trying to use postgresql on windows 71. The installer from edb works fine, apart from an apparently more than eight years old issue, where locale names don't match (my gut tells me windows is reporting inconsistent stuff, like it often does). When i select English, United Kingdom as locale, it fails, and goes to English_United States.1252.

As this is unchangeable after the database cluster creation, i therefore delete it, and attempt to recreate it in the same folder, fixing the locale name problem:

initdb --locale="English_United Kingdom" --lc-monetary="English_United States" -E UTF8 -U postgres -W -A scram-sha-256 -D "C:\Program Files\PostgreSQL\13\data"

Now initdb feels like security without an escape hatch is a good thing, drops priviledges it starts with, and then obviously fails to write anywhere in C:\Program Files, even when originally started as administrator.

creating directory C:/Program Files/PostgreSQL/13/data ... initdb: error: could not create directory "C:/Program Files/PostgreSQL/13/data": Permission denied

How can i reproduce, what the installer would have done, just with the proper locale? I noticed i can create the data folder, and grant full permissions to every user, then initdb works, but the resulting permissions don't look like what the installer produces at all (e.g. regarding the services user NETWORK SERVICE).


Edit: the installer executes getlocales.exe when started, so injecting a different file is difficult. The INITDBOPTS environment variable has lower priority than the installer settings, so it's not useful here.


1: yeah windows 7 is EOL i know..., but postgresql is like 30 years old, so this really shouldn't matter.

4
  • Why don't you just store the data in a different location that doesn't require permission elevation? Vista was more forgiving when writing data to Program Files, with WIndows 7, you must elevate the permissions of the process itself. I suspect initdb is not being elevated despite being started in an elevated command prompt. I assume you are running a supported version of postgresql? (I could careless you using Windows 7, provided postgresql supports it, or you are running a version of postgresql that supports it).
    – Ramhound
    Commented May 27, 2021 at 16:32
  • As could be sneakily guessed from the folder path, i am trying to install postgres13, the most current that was suggested by the website (i'd even install 14 beta, but there was no installer). Using a different folder may be a solution, but the installer can somehow magically do it in "Program Files" as well. I wanted to stick as close to the defaults as possible, which is "Program Files" (i was actually hoping the installer would work out-of-the-box, but apparently not). Tbh i am generally not bound to postgres, but it seemed like a good choice for my use-case (before it failed at install).
    – Doofus
    Commented May 27, 2021 at 16:47
  • My current next attempt will be to compile an alternative getlocales.exe, which just puts "English_United Kingdom" to stdout, and replace the original mid-install. There appears to be an environment variable INITDBOPTS, but the values from the installer supersede it, making it half-useless.
    – Doofus
    Commented May 27, 2021 at 16:49
  • My experience with Office has taught me to ignore file paths, since every current version of Office, is basically “Office 15”. The thread you linked to talked about a .vbs file and how it should do this function in 9.2; I cannot really think of a way to explain why the installer works the way it does.
    – Ramhound
    Commented May 27, 2021 at 16:58

0

You must log in to answer this question.

Browse other questions tagged .