分离已移动或丢失MDF / LDF文件的SQL Server 2005数据库

时间:2021-01-14 00:02:21

I created a document management system for a client which uses SharePoint and SQL Server to store PDF documents. Due to some SAN misconfiguration 3 disks that were holding both MDF and LDF database files dissapeared from the OS one day. We are in the process of recovering the data of the SAN but my question is how do I detach an existing database when it's possible that it's MDF or LDF or both files are no longer where the database expects it to be. I've noticed that even when I try to look at properties SQL Server complains that it can't find one of the files.

我为客户创建了一个文档管理系统,该系统使用SharePoint和SQL Server来存储PDF文档。由于一些SAN配置错误,有一天,同时存在MDF和LDF数据库文件的3个磁盘已从操作系统中消失。我们正在恢复SAN的数据,但我的问题是如何在可能的MDF或LDF或两个文件不再是数据库期望的情况下分离现有数据库。我注意到即使我试图查看属性SQL Server抱怨它找不到其中一个文件。

Do I need to reestablish the disk with the folder structure and MDF/LDF file as it was originally configured for the database in question or can I just configure the database to point to the MDF/LDF in a new location?

我是否需要使用最初为相关数据库配置的文件夹结构和MDF / LDF文件重新建立磁盘,还是只需将数据库配置为指向新位置的MDF / LDF?

1 个解决方案

#1


As far as I know detaching and attaching is the only way to go when you need to point a db to different files (or same files but different location) BUT when the mdf and ldf files are lost the detach (or delete) will fail, as you are experiencing.

据我所知,当你需要将数据库指向不同的文件(或相同的文件但不同的位置)时,分离和附加是唯一的方法但是当mdf和ldf文件丢失时,分离(或删除)将失败,正如你所经历的那样。

If you re-establish mdf and ldf files were they were before it will work - but I am not sure this is what you want.

如果你重新建立mdf和ldf文件,那么它们之前会有用 - 但我不确定这是你想要的。

If you don't have the files you could try Creating dummy mdf and ldf files where they used to be (name must be identical) and you might fool it into letting you detach.

如果你没有这些文件,你可以尝试创建虚拟mdf和ldf文件(名称必须相同),你可能会欺骗它让你分离。

OR

(if you have a backup - guess so!) try to overwrite your db with a restore and you can pick new file names/location.

(如果你有备份 - 猜猜是这样!)尝试用恢复覆盖你的数据库,你可以选择新的文件名/位置。

#1


As far as I know detaching and attaching is the only way to go when you need to point a db to different files (or same files but different location) BUT when the mdf and ldf files are lost the detach (or delete) will fail, as you are experiencing.

据我所知,当你需要将数据库指向不同的文件(或相同的文件但不同的位置)时,分离和附加是唯一的方法但是当mdf和ldf文件丢失时,分离(或删除)将失败,正如你所经历的那样。

If you re-establish mdf and ldf files were they were before it will work - but I am not sure this is what you want.

如果你重新建立mdf和ldf文件,那么它们之前会有用 - 但我不确定这是你想要的。

If you don't have the files you could try Creating dummy mdf and ldf files where they used to be (name must be identical) and you might fool it into letting you detach.

如果你没有这些文件,你可以尝试创建虚拟mdf和ldf文件(名称必须相同),你可能会欺骗它让你分离。

OR

(if you have a backup - guess so!) try to overwrite your db with a restore and you can pick new file names/location.

(如果你有备份 - 猜猜是这样!)尝试用恢复覆盖你的数据库,你可以选择新的文件名/位置。