简体   繁体   English

SQL将数据库从.bak还原到其他计算机-错误

[英]SQL restore database from .bak to a different machine - Errors

I am trying to restore a database from a backup I got on the hosting server. 我正在尝试从托管服务器上获得的备份还原数据库。 I have checked the logical names using: 我已经使用以下命令检查了逻辑名称:

restore FILELISTONLY from 
disk = 'c:\DBBackup2_17092013.bak'

and used them to perform the following query: 并使用它们执行以下查询:

restore database StadlerTest
from disk = 'c:\DBBackup2_17092013.bak'
with replace,
move 'Stadler_base' to 'C:\Program Files\Microsoft SQL
Server\MSSQL10.SQLEXPRESS\MSSQL\StadlerTest.mdf',
move 'Stadler_base_log' to 'C:\Program Files\Microsoft SQL
Server\MSSQL10.SQLEXPRESS\MSSQL\StadlerTest.ldf'

I run the above two queries from master after I created the empty database StadlerTest but I am getting a series of error that sound like these (translation from italian): 在创建空数据库StadlerTest之后,我从master运行了上述两个查询,但是却收到了一系列听起来像这样的错误(意大利语翻译):

""Message 3634, level 16, state 1, row 1 The operating system returned error '5(Access denied.)' during the attempt to 'RestoreContainer::ValidateTargetForCreation' on 'C:\\Program Files\\Microsoft SQL Server\\MSSQL10.SQLEXPRESS\\MSSQL\\StadlerTest.mdf'."" “”消息3634,级别16,状态1,第1行在“ C:\\ Program Files \\ Microsoft SQL Server \\ MSSQL10”上尝试“ RestoreContainer :: ValidateTargetForCreation”时,操作系统返回错误“ 5(访问被拒绝。)”。 SQLEXPRESS \\ MSSQL \\ StadlerTest.mdf'。“”

I am doing something wrong but I do not know what is wrong, I already checked several answers given on SO and other sites but I am not getting it right. 我做错了什么,但我不知道出什么问题了,我已经检查了SO和其他站点上给出的几个答案,但我做对了。 Some help will be appreciated. 一些帮助将不胜感激。 Thanks. 谢谢。

Sounds like a permissions error. 听起来像是权限错误。 SQL Server may not have permissions to create files there. SQL Server可能没有在那里创建文件的权限。 Remember, SQL Server is trying to create the database under its service account, not your windows login. 请记住,SQL Server尝试使用其服务帐户(而不是Windows登录名)创建数据库。 Check the permissions of the SQL Server account, found with all other logins under Security -> Logins in management studio. 检查Management Studio中“安全性”->“登录名”下与所有其他登录名一起找到的SQL Server帐户的权限。

However, you should not create databases on the C drive. 但是,您不应在C驱动器上创建数据库。 If they grow and the C drive runs out of space your whole computer and operating system will tank. 如果它们增长并且C驱动器空间不足,则整个计算机和操作系统都会崩溃。 If at all possible, put the database files on a different drive. 如果可能,请将数据库文件放在其他驱动器上。 If this is just for personal testing use, that is fine but not for any important system. 如果这仅用于个人测试,那很好,但不适用于任何重要的系统。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM