简体   繁体   English

Windows:无法删除myDB.mdf,因为该文件已在系统中打开

[英]Windows: Cannot delete myDB.mdf because the file is open in System

This is the strangest thing ever. 这是有史以来最奇怪的事情。 My company's product uses a database file with Microsoft SQL Server 2008 R2, let's just say it's named myDB.mdf . 我公司的产品使用带有Microsoft SQL Server 2008 R2的数据库文件,我们只说它名为myDB.mdf I want to delete that file and replace it with a same-named database from another system. 我想删除该文件,并用另一个系统中的同名数据库替换它。 So I try to delete it, and of course I can't because it's in use by some process. 因此,我尝试将其删除,但是由于某些进程正在使用它,我当然不能删除它。 I reboot specifically to ensure that nothing's still running that has that file open, and I still can't delete it (same reason). 我专门重新启动以确保打开该文件的所有文件仍在运行,并且我仍然无法删除它(同样的原因)。 I fire up Sysinternals ProcessExplorer and Find->Find Handle or DLL and enter the filename. 我启动Sysinternals ProcessExplorer并找到->查找句柄或DLL,然后输入文件名。 The process that has it open is named 'System' and has a PID of 4. So I go to Control Panel -> Programs and Features and one-by-one, uninstall all of the components of Microsoft SQL Server 2008 R2. 打开它的进程名为“ System”,PID为4。因此,我转到“控制面板”->“程序和功能”,然后一步一步地卸载Microsoft SQL Server 2008 R2的所有组件。 Still can't delete it. 仍然无法删除它。 Oh, I have MS SQL Server 2012 installed... maybe that's it. 哦,我已经安装了MS SQL Server 2012 ...也许就是这样。 Uninstall all components of that. 卸载其中的所有组件。 And some other SQL thing from Microsoft, uninstall that too. 还有Microsoft的其他一些SQL东西,也请卸载它。 Still can't delete it. 仍然无法删除它。 Reboot. 重启。 Don't open ANYTHING, and still can't delete it. 不要打开任何东西,仍然无法删除它。 It gives the error "File In Use: The action can't be completed because the file is open in System. Close the file and try again. [Try Again] [Cancel]". 它给出错误“正在使用文件:由于在系统中打开了文件,因此无法完成操作。关闭文件,然后重试。[重试] [取消]”。 I opened up Control Panel -> Programs and Features again, and confirmed that there are no remaining SQL-ish things. 我再次打开“控制面板”->“程序和功能”,并确认没有SQL残留的东西。 And the file's icon is now a white sheet of paper with the top right edge folded over (ie it has no file association). 文件的图标现在是一张白纸,右上角折叠了(即没有文件关联)。

Any idea how I can make 'System' not open the file so I can delete it? 知道如何使“系统”无法打开文件,以便将其删除吗?

The correct action was to right-click on the database in SQL Management Studio and choose Delete. 正确的操作是右键单击SQL Management Studio中的数据库,然后选择“删除”。 Undoing the steps you've taken may be very difficult. 撤消已采取的步骤可能非常困难。 I'm assuming/hoping this is a dev server. 我假设/希望这是一个开发服务器。 Can you revert to snapshot or nuke the server and install on another? 您可以还原到快照或核对服务器并在另一台服务器上安装吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法创建文件“*.mdf”,因为它已经存在 - Cannot create file '*.mdf' because it already exists 如何删除生成的带有打开连接的 mdf 文件? - How do you delete a generated mdf file with open connections? 如何打开mdf文件 - How to open the mdf file 无法打开备份设备“/var/opt/mssql/backup/MyDB.bak”。 操作系统错误 5(访问被拒绝。) - Cannot open backup device '/var/opt/mssql/backup/MyDB.bak'. Operating system error 5(Access is denied.) 无法打开文件.mdf/.ldf。 操作系统错误 5:5“(拒绝访问。)” - 尝试用新文件替换 .mdf/.ldf 文件 - Unable to open the file .mdf/.ldf. Operating system error 5: 5“(Access is denied.)” - Trying to replace .mdf/.ldf file with new one 数据库无法打开,因为它的版本。 将 .mdf 文件连接到 Visual Studio 2019 - The database cannot be opened because of it's version. Connecting .mdf file to Visual Studio 2019 无法打开数据库'[path \\ MDF文件],因为它是版本661。此服务器支持版本655和更早的版本 - The database '[path\MDF file] cannot be opened because it is version 661. This server supports version 655 and earlier 无法将mdf文件附加为数据库 - Cannot attach mdf file as database mdf 无法打开,因为版本是 661 而我的数据库支持 665 - mdf can not open because version is 661 and my database support 665 在datagridview中打开SQL Server MDF文件 - Open SQL Server MDF file in datagridview
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM