我在本地机器上创建了一个数据库,然后对表DataLabTables进行了名为tables.bak的备份。

我将备份移动到远程机器,没有该表,并尝试进行恢复,但得到以下错误:

sqlclient . sqlerror:操作系统返回 尝试访问时错误'5(访问被拒绝。)' 'RestoreContainer::ValidateTargetForCreation'在c:\程序 文件\Microsoft SQL Server\MSSQL.1\MSSQL\DataLabTables.mdf `。

如果这是问题所在,我该如何修正我的权利?


当前回答

Another scenario could be the existence of multiple database paths. First, make note of the path where new databases are currently being stored. So if you create a new empty database and then do Tasks/Restore, make sure that the path the restore is trying to use is the same directory that the empty database was created in. Even if the restore path is legal, you will still get the access denied error if it is not the current path you are working with. Very easy to spot when the path is not legal, much harder to spot when the path is legal, but not the current path.

其他回答

在这个问题上也浪费了几个小时。尽管如此:

“拒绝访问”在我的情况下确实意味着“拒绝访问”。我的windows设备上的mssqlstudio用户帐户没有错误消息中指定的文件夹的完全控制权。我完全控制了它。访问不再被拒绝,恢复成功。

为什么档案室把文件夹锁起来了?谁知道呢?我已经有足够多的问题要解决了,不用再回答了。

我也遇到过类似的问题。我试图恢复一个2005年的。bak文件,我收到了完全相同的错误。我也选择了覆盖选项,但无济于事。

我的解决方案是通过转到文件夹并通过属性屏幕编辑访问权限,授予SQL用户对所讨论的目录的访问权限。

如果路径是正确的,但服务帐户不是数据文件的所有者(但它仍然有足够的读/写访问权限),也会发生这种情况。如果将文件的权限重置为与文件夹的权限匹配(当然,在服务停止时),就会发生这种情况。

在这种情况下,最简单的解决方案是分离每个数据库并再次附加它(因为在附加时所有者将更改为服务帐户)。

我有这个问题,我以管理员身份登录,它解决了这个问题。

我也有同样的问题。原来我的SQL Server和SQL Server代理服务登录时在网络服务帐户下运行,该帐户没有执行备份恢复的写访问权。

我将这两个服务都更改为以本地系统帐户登录,这就解决了问题。