gpt4 book ai didi

sql-server - 将 MSSQL .bak 文件还原到 Centos MSSQL,但不能使用备份文件

转载 作者:行者123 更新时间:2023-12-04 19:42:14 30 4
gpt4 key购买 nike

我试图恢复 centos 服务器内的 mssql 文件。 .bak 文件已放入服务器并将用户设为 mssql。

[![在此处输入图像描述][1]][1]

这是我运行此命令进行恢复时的错误。

sqlcmd -S localhost -U SA -Q "BACKUP DATABASE [DataDB] TO DISK = N'/var/opt/mssql/data/DataDB.bak' WITH NOFORMAT, NOINIT, NAME = 'demodb-full', SKIP, NOREWIND, NOUNLOAD, STATS = 10"

输入此命令后,它显示此错误。
[![在此处输入图像描述][2]][2]

对于这种问题,如何通过 centos 更改扇区大小?或者必须使用 SQL 资源管理器管理。
[root@RAC data]# sqlcmd -S localhost -U SA -Q "RESTORE DATABASE [DataDB] FROM DISK = N'/var/opt/mssql/data/DataDB.bak' WITH FILE = 1, NOUNLOAD, REPLACE, NORECOVERY, STATS = 5"
Password:
Msg 5133, Level 16, State 1, Server RAC, Line 1
Directory lookup for the file "C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\DataDB.mdf" failed with the operating system error 2(The system cannot find the file specified.).
Msg 3156, Level 16, State 3, Server RAC, Line 1
File 'DataDB' cannot be restored to 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\DataDB.mdf'. Use WITH MOVE to identify a valid location for the file.
Msg 5133, Level 16, State 1, Server RAC, Line 1
Directory lookup for the file "C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\DataDB_log.ldf" failed with the operating system error 2(The system cannot find the file specified.).
Msg 3156, Level 16, State 3, Server RAC, Line 1
File 'DataDB_log' cannot be restored to 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\DataDB_log.ldf'. Use WITH MOVE to identify a valid location for the file.
Msg 3119, Level 16, State 1, Server RAC, Line 1
Problems were identified while planning for the RESTORE statement. Previous messages provide details.
Msg 3013, Level 16, State 1, Server RAC, Line 1
RESTORE DATABASE is terminating abnormally.

最佳答案

我不是为什么您要先将备份副本放在服务器上,而您正在做的是备份它;这是没有意义的。如果您尝试 RESTORE数据库确定,但您正在执行 BACKUP .考虑到问题是您尝试覆盖的文件具有不同的扇区格式,我建议先删除文件然后备份:

rm /var/opt/mssql/data/DataDB.bak && sqlcmd -S localhost -U SA -Q "BACKUP DATABASE [DataDB] TO DISK = N'/var/opt/mssql/data/DataDB.bak' WITH NOFORMAT, NOINIT, NAME = 'demodb-full', SKIP, NOREWIND, NOUNLOAD, STATS = 10"

关于sql-server - 将 MSSQL .bak 文件还原到 Centos MSSQL,但不能使用备份文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53666780/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com