我想备份数据库。为此,我使用以下命令:
BACKUP DATABASE test4 TO DISK = 'C:\\db_backup'
go
BACKUP LOG test4 TO DISK = 'C:\\log_backup' with NORECOVERY
起初有一个错误,但在根据这个答案Msg 3201, Level 16, State 1, Line 1 Cannot open backup device Operating system error 5(Отказано в доступе.).
将 NT Service\MSSQLSERVER 更改为内置帐户 - 本地系统之后。一切似乎都有效:
Processed 480 pages for database 'test4', file 'test4' on file 1.
Processed 2 pages for database 'test4', file 'test4_log' on file 1.
BACKUP DATABASE successfully processed 482 pages in 0.060 seconds (62.695 MB/sec).
Processed 5 pages for database 'test4', file 'test4_log' on file 1.
BACKUP LOG successfully processed 5 pages in 0.015 seconds (2.604 MB/sec).
然而,在那之后,在对象资源管理器中,test4 数据库变成了:test4 (Restoring...)。并且数据库不能再使用了。Database 'test4' cannot be opened. It is in the middle of a restore.
- 如果我只做了备份,没有运行恢复,为什么会出现正在恢复状态?
- 为什么不能再使用数据库?使用 test4 给出
Database 'test4' cannot be opened. It is in the middle of a restore.
?
如何解决以上问题?
按照要求,服务器做了:
备份 (Transact-SQL)
要将数据库恢复到工作状态,请运行: