简体   繁体   English

将TDE加密的数据库备份还原到其他服务器-SQL Server 2008

[英]Restoring a TDE Encrypted Database Backup to a Different Server - SQL Server 2008

Two years ago, I used the below code to encrypt (TDE) the database in SQL Server 2008 两年前,我使用下面的代码在SQL Server 2008中加密(TDE)数据库

USE MASTER; 
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'Strong Password'
GO

USE MASTER; 
CREATE CERTIFICATE DB_CER WITH SUBJECT = 'DB Certificate'
GO

USE DB

GO 
CREATE DATABASE ENCRYPTION KEY WITH 
ALGORITHM = AES_256 ENCRYPTION BY 
SERVER CERTIFICATE DB_CER ; 
GO

USE  DB
ALTER DATABASE  DB
SET ENCRYPTION ON ; 
GO

USE master; 
GO 
BACKUP CERTIFICATE DB_CER 
TO FILE = 'c:\Backup\certificate_DB_Certificate.cer'
WITH PRIVATE KEY
(FILE = 'c:\Backup\certificate_DB_Key.pvk',
ENCRYPTION BY PASSWORD = 'Strong Password')

I took full backup for DB Database and the certificate_DB_Certificate.cer & certificate_DB_Key.pvk and save it to my hard drive. 我对数据库数据库以及certificate_DB_Certificate.cer和certificate_DB_Key.pvk进行了完整备份,并将其保存到硬盘中。 After two years I used different PC to restore the MASTER KEY & the CERTIFICATE, so I can to restore the Backup file 两年后,我使用另一台PC还原了MASTER KEY和CERTIFICATE,因此我可以还原备份文件

CREATE CERTIFICATE DB_CER
FROM FILE = 'D:\Backup\certificate_DB_Certificate.cer'     
WITH PRIVATE KEY (FILE = 'D:\Backup\certificate_OCV_DB_Key.pvk', 
DECRYPTION BY PASSWORD = 'Strong Password')

After I run the code I got this message 运行代码后,我收到此消息

Warning: The certificate you created is expired. 警告:您创建的证书已过期。

So I delete the CERTIFICATE and I change the Pc date to 2015/Jun (the date when The CERTIFICATE was created) then I re-create the certificate again with successfully completed command, but when I restore the backup file I got this message 因此,我删除了CERTIFICATE,并将Pc日期更改为2015 / Jun(创建CERTIFICATE的日期),然后使用成功完成的命令再次重新创建了证书,但是当我还原备份文件时,我收到了此消息

Restore of database 'DB' failed. 恢复数据库“ DB”失败。
(Microsoft.SqlServer.Management.RelationalEngineTasks) System.Data.SqlClient.SqlError: Cannot find server certificate with thumbprint '0xFC01AD2683E08A4C8CD6A0F037DC66A945FBA44D'. (Microsoft.SqlServer.Management.RelationalEngineTasks)System.Data.SqlClient.SqlError:找不到指纹为'0xFC01AD2683E08A4C8CD6A0F037DC66A945FBA44D'的服务器证书。 (Microsoft.SqlServer.SmoExtended) (Microsoft.SqlServer.SmoExtended)

Any suggestions? 有什么建议么?

The "expired certificate" message was a warning, not an error. “证书过期”消息是警告,不是错误。 You can still use an expired certificate. 您仍然可以使用过期的证书。

Delete the certificate you created with the changed date, then restore the certificate again with the correct date. 删除使用更改的日期创建的证书,然后使用正确的日期再次还原该证书。

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

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