[英]Restore DB from MDF file, lost LDF and DB was not cleanly shutdown
My dev DB server was formatted by some admin without my knowledge. 我的开发数据库服务器是由某些管理员在不知情的情况下格式化的。 Thankfully I had .mdf file kept in some other drive but .ldf was in its default location.
幸运的是,我将.mdf文件保存在其他驱动器中,但.ldf处于其默认位置。 Since I don't have DB backup I am now left with .mdf file.
由于我没有数据库备份,因此现在只剩下.mdf文件。 I googled and found various tricks to restore DB from .mdf file.
我用谷歌搜索,发现了各种技巧来从.mdf文件还原数据库。 Since database was not cleanly shutdown none of the tricks worked.
由于没有彻底关闭数据库,因此没有任何技巧可以起作用。 I have SQL Server 2008 SP2 installed in my machine.
我的机器上安装了SQL Server 2008 SP2。 As I remember lost DB server was SQL Server 2005 instance.
我记得丢失的数据库服务器是SQL Server 2005实例。 Please let me know how I could recover my database.
请让我知道如何恢复数据库。
Tricks i tried: 我尝试过的技巧:
CREATE DATABASE Monitoring ON (FILENAME = N'D:\\Dump\\Data\\Monitoring.MDF') FOR ATTACH_REBUILD_LOG
sp_attach_single_file_db N'Monitoring', N'D:\\Dump\\Data\\Monitoring_Data.MDF'
In all above I got 在以上所有内容中
Incorrect DBCC statement.
DBCC语句不正确。 Check the documentation for the correct DBCC syntax and options.
检查文档以获取正确的DBCC语法和选项。
Then I tried DBCC REBUILD_LOG('Monitoring',N'C:\\Program Files ..MSSQL\\Data\\Monitoring_log.ldf')
which resulted in: 然后我尝试了
DBCC REBUILD_LOG('Monitoring',N'C:\\Program Files ..MSSQL\\Data\\Monitoring_log.ldf')
,结果是:
Incorrect DBCC statement.
DBCC语句不正确。 Check the documentation for the correct DBCC syntax and options.” error.
检查文档以获取正确的DBCC语法和选项。”错误。
Here are some notes (for SQL 2000) that might help. 以下是一些注释(对于SQL 2000)可能会有所帮助。 I've never tried these personally.
我从来没有亲自尝试过这些。
Put the DB into Emergency Bypass Status by doing the following: 通过执行以下操作,将数据库置于紧急旁路状态:
sp_configure 'allow', 1 go reconfigure with overide. update master..sysdatabases set status=32768 where dbid=5 --check this ID is for your db
Stop the SQL service (instance). 停止SQL服务(实例)。
Execute the following in QM: 在质量管理中执行以下步骤:
select dbid, status, name from master..sysdatabases dbcc rebuild_log ('dbname', 'full path and LDF name')
Revert DB from Emergency Bypass Status by executng in QM: 通过在QM中执行,从紧急旁路状态还原DB:
update master..sysdatabases set status=16 where dbid=5 --Check this ID for your db
Cleanup by executing the following in QM: 通过在QM中执行以下操作进行清理:
sp_configure 'allow', 0 go reconfigure with override
Try This: 尝试这个:
ALTER DATABASE EmpDataBase REBUILD LOG ON (NAME=$DatabaseName$,FILENAME=N'$Path\\DatabaseName.ldf$') ALTER DATABASE EmpDataBase重建登录(NAME = $ DatabaseName $,FILENAME = N'$ Path \\ DatabaseName.ldf $')
GO 走
DBCC CHECKDB DBCC CHECKDB
ALTER DATABASE $DatabaseName$ SET MULTI_USER ALTER DATABASE $ DatabaseName $ SET MULTI_USER
GO 走
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.