delete old PostgreSQL data directory in win7

纵然是瞬间 提交于 2021-02-10 20:31:49

问题


i'm not able to delete my old data directory in windows 7. i already uninstalled PostgreSQL, but there's still the system service user account "postgres", who's the only one with access-rights to the folder.

possible solution would be to develop a service, running as "postgres" user, which deletes the folder, but there must be an easier way?


回答1:


I haven't used Windows 7, but if I recall correctly, there should be a way to start an explorer session (the filemanager, not IE) under the Postgres user and then remove it.

Otherwise, you might be able to, by logging in as an Administrator, add rights for Administrators to modify that directory and the parent directory and after that you should be able to remove it.

I am not certain if it is possible for an administrator to remove the directory directly, but it should be possible for one to add the rights to do so.

Update: I just installed PostgreSQL and tested it in Vista, it might work the same in Windows 7. It seems like they have fixed the permission stuff, so the tip above doesn't work (changing the permissions).

However, if the system account is still there, you can access it in the Computer Management. Add it to a regular user group (like Users or Administrators) and then you should be able to login with it and after that remove the directory.




回答2:


Its simple. Just open up Command Prompt as admin, and type

net user

Then press the return key, you'll see the user accounts within your OS. Also you'll notice postgres listed there. Inorder to remove it, type the following:-

net user postgres /del

And the return key. Voila, you're done. Just to make sure everything is done completely, check your 'USERS' folder in C: drive, or whichever concerned and remove the folder called 'postgres' if present. Done! :)




回答3:


As an administrator take ownership of the directory in question - in Windows Explorer - right-click on it, 'Properties', 'Security', 'Advanced', 'Owner', and from the list under 'Change owner to' select your account. Then delete it.




回答4:


You have to remove the user too.

Open a command line and type net user "login of the user" /delete




回答5:


The post kind of old, but if what is intended is the same I intended (delete "postgres" account), the solution could be this:

  1. Open cmd as administrator
  2. Run the command: net user postgres /delete


来源:https://stackoverflow.com/questions/901302/delete-old-postgresql-data-directory-in-win7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!