如何恢复“包含”的数据库?

Dav*_*vid 41 sql-server backup restore contained-database

我最近尝试将来自网络实例的备份恢复到我的本地开发 SQL Server。令我惊讶的是,我收到以下错误消息:

消息 12824,级别 16,状态 1,第 3 行 sp_configure 值 'contained database authentication' 必须设置为 1 才能恢复包含的数据库。您可能需要使用 RECONFIGURE 来设置 value_in_use。消息 3013,级别 16,状态 1,第 3 行 RESTORE DATABASE 异常终止。

我必须遵循哪些步骤才能成功恢复数据库?

Dav*_*vid 64

为了将包含的数据库恢复到 sql server 的不同实例,在这种情况下是我的本地服务器,“启用包含的数据库”属性必须设置为True

您可以从管理工作室执行此操作:

  1. 右键单击服务器实例,选择属性
  2. 选择Advanced页面,将Containment下的属性值设置为True
  3. 继续恢复数据库备份。
  4. ALTER AUTHORIZATION ON DATABASE::ReplaceThisWithYourDatabaseName TO ReplaceThisWithLeastPrivilegeUser;

以下是我实际用于启用/禁用遏制的脚本行:

-- Enable "contained database authentication"
EXEC sp_configure 'contained', 1;
RECONFIGURE;

-- Disable "contained database authentication"
EXEC sp_configure 'contained', 0;
-- Force disabling of "contained database authentication"
RECONFIGURE WITH OVERRIDE;
Run Code Online (Sandbox Code Playgroud)

更多信息请参考:http :
//www.sqlsoldier.com/wp/sqlserver/protectionfromrestoringabackupofacontaineddatabase


小智 5

您是否尝试过执行错误所描述的操作?

USE master
GO
sp_configure 'show   advanced options', 1
GO
RECONFIGURE
GO
sp_configure 'CONTAINED DATABASE AUTHENTICATION', 1
GO
RECONFIGURE
GO
sp_configure 'show   advanced options', 0 
GO
RECONFIGURE
GO
Run Code Online (Sandbox Code Playgroud)