无法删除SQLServer2005数据或日志文件

发布于 2024-07-13 05:39:19 字数 206 浏览 12 评论 0原文

我尝试恢复备份,但一直收到操作系统错误 32 - 由于正在使用而无法删除。

无法弄清楚是什么锁定了数据和日志文件 - 所以我重新启动了机器,停止了服务,但仍然没有运气。

然后我删除了数据库,但数据和日志文件仍然存在。

再次重新启动 - 尝试删除它们,但看起来没有什么可做的,Windows 不允许我这样做。

任何想法?

I was trying to restore a backup but I kept getting OS error 32 - cannot delete because in use.

Couldn't figure out what was locking the data and log files - so I rebooted the machine, stopped the service but still no luck.

Then I deleted the DB but data and log files are still there.

Rebooted again - tried to delete them but looks like there's no thing to do, windows doesn't let me.

Any idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

甜心小果奶 2024-07-20 05:39:19

防病毒软件是一种可以捕获 DBA 的软件 - MDF/LDF 文件非常大,我见过 AV 软件抓住文件锁来扫描它们的情况,但由于文件大小的原因,它需要很长时间。 您可以尝试停止防病毒服务。

另一种是备份程序 - 如果您使用基于文件的备份(例如 Backup Exec 或 NetBackup),它们当时可能会尝试运行文件备份。 检查是否有任何备份软件服务,停止这些服务,然后尝试删除文件。

您可能还安装了多个 SQL Server 实例,并且这可能属于另一个实例,而不是您正在使用的实例。

Antivirus software is one that catches DBAs - the MDF/LDF files are pretty big, and I've seen cases where the AV software grabs a lock on the files to scan them, but it takes forever due to the file size. You might try stopping your antivirus service.

Another one is backup programs - if you're using file-based backups (like Backup Exec or NetBackup) they may be trying to run a file backup at the time. Check for any backup software services, stop those, and then try to delete the files.

You might also have multiple instances of SQL Server installed, and this might belong to another instance, not the one you were working with.

被翻牌 2024-07-20 05:39:19

使用 Process Explorer,这是一个 Microsoft 工具,它会告诉您当前哪个进程锁定了文件,这会告诉您在删除文件之前需要停止/关闭什么。

以下是有关找出谁锁定了文件的教程:

http://windowsxp.mvps.org/processlock。嗯

Use Process Explorer, a Microsoft tool that will tell you which process currently has a file locked, which will tell you what you need to stop/close before you can delete a file.

Here's a tutorial on finding out who has a file locked:

http://windowsxp.mvps.org/processlock.htm

七度光 2024-07-20 05:39:19

我遇到了类似的错误,在数据库分离后我无法删除数据文件和日志文件。

我收到错误消息说需要“管理员权限”。

通过更改文件的权限已解决。
进入运行提示-> 输入“Windows 资源管理器”-> 以管理员身份运行并访问该文件。

右键单击文件名并选择“属性”。转到“安全选项卡”并添加具有完全权限的域帐户。

现在,您将能够删除该文件。

I faced the similar error where I wasn't able to delete the datafiles and logfiles after the databases were detached.

I was getting the error saying "Administrator Privilege" is required.

It was resolved by changing the permission of the file.
Go to run prompt -> type "windows explorer" -> Run as administrator and access the file.

Right click the filename and select "Properties'.Go to "Security Tab" and add your domain account with full permissions.

Now, you would be able to delete the file.

世界等同你 2024-07-20 05:39:19

您应该能够分离(而不是删除)数据库,然后移动或删除数据文件。

Microsoft 知识库。

You should be able to detach (not delete) the database and then move or remove the data files.

Microsoft KB.

层林尽染 2024-07-20 05:39:19

您删除了 SSMS 中的数据库,但文件仍然存在? (如果您“删除”了条目,则不再需要分离”
您可能选中了“保留数据文件”复选框

,但我想重新启动应该允许您删除实际的 .mdf 和 .ldf 文件
如果没有,请尝试启动到安全模式并删除实际文件

You deleted the DB's in SSMS but the files are still there? (shouldn't need to detach anymore if you "deleted" the entries"
You probably checked the "Keep data files" checkbox

but I imagine a reboot should allow you to delete the actual .mdf and .ldf files
If not, try booting into Safe mode and delete the actual files then

乖乖公主 2024-07-20 05:39:19

我遇到了“系统正在使用”错误的另一个原因。 就我而言,在与所有实例分离并重新启动后,我无法删除文件。 这不是安全权限问题。 它也没有被任何程序使用,因为进程资源管理器没有显示任何使用它的进程。 就我而言,原因是Visual Studio TFS 对 mdf 的检出不当。 看来如果您签出文件然后松开与 TFS 服务器的连接 - 您将无法删除或重命名带有“系统正在使用”的文件。 即使没有启动VS。 安全模式下可以删除文件。 而且,更重要的是 - 如果您让 TFS 重新联机并执行正确的签入,文件就可以正确解锁。

I encountered another reason for "in use by system" error. In my case I was not able remove file after detaching from all instances and rebooting. This was not security permissions problem. Nor it was used by any program as process explorer did not show any process using it. In my case the cause was improper check out of mdf by Visual Studio TFS. It seems if you checkout file and then loose connection to TFS server - you will not be able to delete or rename file with "in use by System". Even without VS started. File can be deleted in safe mode. And, what is more important - file can be unlocked properly if you get TFS back online and preform proper CheckIn.

心如荒岛 2024-07-20 05:39:19

我遇到过与此类似的错误,但这是权限问题而不是其他问题。 数据库是在不同的用户下创建的,普通管理员帐户根本没有LDF/MDF文件的权限。

其他症状是管理员无法创建同名的数据库,并且第三方应用程序无法执行数据导入(因为它删除并重新创建了数据库)

I've encountered an error similar to this, but it was a permissions issue rather than anything else. Database was created under a different user, and the normal administrator account did not have permissions to LDF/MDF files at all.

Other symptoms were that administrator couldn't create a databasse of the same name, and that a third party application could not do a data import (as it dropped and recreated a database)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文