且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在SQL Server 2005数据库之间传输sql加密数据?

更新时间:2022-11-25 09:38:26

您所指的对称密钥是数据库主密钥(DMK)。它们保留在数据库级别,因此对另一个SQL Server的备份/还原应该可以正常工作(不同服务帐户的注意事项,这是线程暗示)

The Symmetric keys you are referring to are Database Master Keys (DMKs). They are held at the Database level, so a backup/restore to another SQL server should work OK (with the caveat of differing service accounts, which this thread alludes to)

在做任何事情之前,请确保你有一个钥匙的备份(大概你已经这样做了):

Before you do anything make sure you have a backup of your keys (presumably you've already done this):

USE myDB
GO
BACKUP MASTER KEY TO FILE = 'path_to_file'
    ENCRYPTION BY PASSWORD = 'password'
GO

从此文章:

From this article:


创建数据库主密钥时,
a副本将使用附带的
密码进行加密并存储在当前的
数据库中。副本也加密
与服务主密钥,并在主数据库中存储

的副本,DMK允许服务器
自动解密DMK,一个
功能被称为自动密钥
管理。没有自动密钥
管理,您必须使用OPEN
MASTER KEY语句,并在每次您要
时使用
证书加密和/或解密数据时提供
密码和依赖
DMK的密钥来安全。使用自动密钥
管理,OPEN MASTER KEY
语句和密码不需要

When you create a Database Master Key, a copy is encrypted with the supplied password and stored in the current database. A copy is also encrypted with the Service Master Key and stored in the master database. The copy of the DMK allows the server to automatically decrypt the DMK, a feature known as "automatic key management." Without automatic key management, you must use the OPEN MASTER KEY statement and supply a password every time you wish to encrypt and/or decrypt data using certificates and keys that rely on the DMK for security. With automatic key management, the OPEN MASTER KEY statement and password are not required.