SQL 2012
我正在尝试在本地计算机中恢复完整备份数据库。备份已从服务器数据库中获取。我尝试了向导选项和语法选项。
RESTORE DATABASE MyDatabase
FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Backup\DB_Backup.bak'
WITH REPLACE
在执行上述语法时,我收到如下错误消息。
错误消息说,原始备份文件 - .mdf和.ldf仍然映射到原始服务器路径。
Msg 3156, Level 16, State 3, Line 1
File 'DB_Backup_Data' cannot be restored to 'D:\My Path\Data\DB_Backup.mdf'. Use WITH MOVE to identify a valid location for the file.
Msg 3156, Level 16, State 3, Line 1
File 'DB_Backup_Log' cannot be restored to 'D:\My Path\Data\DB_log.ldf'. Use WITH MOVE to identify a valid location for the file.
如何将.ldf和.mdf重新映射到本地计算机并还原数据库
答案 0 :(得分:1)
试试这个:
RESTORE DATABASE [MyDatabase]
FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Backup\DB_Backup.bak'
WITH MOVE 'MyDatabase_Data' TO 'D:\My Path\Data\DB_Backup.mdf',
MOVE 'MyDatabase_Log' TO 'D:\My Path\Data\DB_log.ldf',
REPLACE
答案 1 :(得分:0)
您需要指示SQL Server将文件移动到本地计算机上的正确位置 - 例如:
RESTORE DATABASE MyDatabase
FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Backup\DB_Backup.bak'
WITH REPLACE,
MOVE 'DB_Data' TO 'C:\MyData\MyDatabase_Data.mdf',
MOVE 'DB_Log' TO 'C:\MyLog\MyDatabase_Log.ldf'
您需要为DB_Data和DB_Log替换正确的逻辑文件名,并在本地计算机上为路径替换正确的数据库物理文件名。
答案 2 :(得分:0)
转到还原数据库.. ,然后添加要还原的.bak
文件。
之后转到选项并更改还原为路径