SQL Server:数据库陷入“恢复”状态

吃可爱长大的小学妹 提交于 2020-08-17 18:13:08

问题:

I backed up a database: 我备份了一个数据库:

BACKUP DATABASE MyDatabase
TO DISK = 'MyDatabase.bak'
WITH INIT --overwrite existing

And then tried to restore it: 然后尝试恢复它:

RESTORE DATABASE MyDatabase
   FROM DISK = 'MyDatabase.bak'
   WITH REPLACE --force restore over specified database

And now the database is stuck in the restoring state. 现在数据库仍处于恢复状态。

Some people have theorized that it's because there was no log file in the backup, and it needed to be rolled forward using: 有些人认为这是因为备份中没有日志文件,需要使用以下方式前滚:

RESTORE DATABASE MyDatabase
WITH RECOVERY 

Except that, of course, fails: 当然,除此之外,失败:

Msg 4333, Level 16, State 1, Line 1
The database cannot be recovered because the log was not restored.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.

And exactly what you want in a catastrophic situation is a restore that won't work. 确切地说,在灾难性的情况下你想要的是一种无法恢复的恢复。


The backup contains both a data and log file: 备份包含数据和日志文件:

RESTORE FILELISTONLY 
FROM DISK = 'MyDatabase.bak'

Logical Name    PhysicalName
=============   ===============
MyDatabase    C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\MyDatabase.mdf
MyDatabase_log  C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\MyDatabase_log.LDF

解决方案:

参考一: https://stackoom.com/question/2BWh/SQL-Server-数据库陷入-恢复-状态
参考二: https://oldbug.net/q/2BWh/SQL-Server-Database-stuck-in-Restoring-state
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!