windows 删除win7中旧的PostgreSQL数据目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/901302/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
delete old PostgreSQL data directory in win7
提问by 5andr0
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.
我无法在 Windows 7 中删除旧数据目录。我已经卸载了 PostgreSQL,但系统服务用户帐户“postgres”仍然存在,他是唯一一个对该文件夹具有访问权限的用户。
possible solution would be to develop a service, running as "postgres" user, which deletes the folder, but there must be an easier way?
可能的解决方案是开发一个服务,以“postgres”用户身份运行,删除文件夹,但必须有更简单的方法?
采纳答案by Jimmy Stenke
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.
我没有使用过 Windows 7,但如果我没记错的话,应该有一种方法可以在 Postgres 用户下启动资源管理器会话(文件管理器,而不是 IE),然后将其删除。
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).
更新:我刚刚安装了 PostgreSQL 并在 Vista 中对其进行了测试,它可能在 Windows 7 中也能正常工作。似乎他们已经修复了权限问题,因此上面的提示不起作用(更改权限)。
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.
但是,如果系统帐户仍然存在,您可以在计算机管理中访问它。将它添加到常规用户组(如用户或管理员),然后您应该能够使用它登录,然后删除目录。
回答by Cray
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:-
然后按回车键,您将在操作系统中看到用户帐户。您还会注意到那里列出了 postgres。要删除它,请键入以下内容:-
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! :)
还有回车键。瞧,你完成了。只是为了确保一切都已完成,请检查 C: 驱动器中的“USERS”文件夹或任何相关的文件夹,并删除名为“postgres”的文件夹(如果存在)。完毕!:)
回答by Milen A. Radev
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.
作为管理员取得相关目录的所有权 - 在 Windows 资源管理器中 - 右键单击它,“属性”、“安全”、“高级”、“所有者”,然后从“将所有者更改为”下的列表中选择您的帐户. 然后删除它。
回答by Milen A. Radev
You have to remove the user too.
您也必须删除用户。
Open a command line and type net user "login of the user" /delete
打开命令行并输入 net user "login of the user" /delete
回答by Geocarlos
The post kind of old, but if what is intended is the same I intended (delete "postgres" account), the solution could be this:
帖子有点旧,但如果我的意图是相同的(删除“postgres”帐户),解决方案可能是这样的:
- Open cmdas administrator
- Run the command:
net user postgres /delete
- 以管理员身份打开cmd
- 运行命令:
net user postgres /delete