尝试恢复加密数据库时遇到问题

发布于 2024-11-29 21:11:22 字数 995 浏览 1 评论 0原文

我试图将加密数据库从默认服务器复制到我的服务器以进行测试,

但我在这样做时遇到了麻烦,因为我从未这样做过 所以我要解释我的程序和我首先遇到的错误

我创建了一个主密钥:

USE master
GO
CREATE MASTER KEY ENCRYPTION BY PASSWORD ='DB-PaSSw0rD'
GO

现在一切都很好:
命令成功完成。

然后我通过导入在默认服务器上创建的证书来创建证书:

CREATE CERTIFICATE TDECERT
FROM FILE = 'C:\temp\TDECert.cer'
WITH PRIVATE KEY (FILE = 'C:\temp\TDECertKey.pvk' , 
DECRYPTION BY PASSWORD ='pAssW0rD')
GO

但我得到:
消息 15581,级别 16,状态 1,第 1 行

请在执行此操作之前在数据库中创建主密钥或在会话中打开主密钥。

解决此问题尝试打开主钥匙:

OPEN MASTER KEY DECRYPTION BY PASSWORD ='DB-PaSSw0rD'
ALTER MASTER KEY ADD ENCRYPTION BY SERVICE MASTER KEY

但我得到: 找不到对称密钥“主密钥”,因为它不存在或您没有权限。

然后为了解决第二个问题,我尝试授予它访问权限:

GRANT CONTROL ON CERTIFICATE :: TDECERT To Administrator

但我得到:
找不到证书“TDECERT”,因为它不存在或您没有权限。

提前感谢您的宝贵时间

Im trying to copy an encrypted database from the default server to my server for testing purposes

but im having troubles doing so because i have never done it
so im going to explain my procedure and the errors i got

first i create a master key :

USE master
GO
CREATE MASTER KEY ENCRYPTION BY PASSWORD ='DB-PaSSw0rD'
GO

all is good for now :
Command(s) completed successfully.

then i create a certificate by importing the certificate created on the default server:

CREATE CERTIFICATE TDECERT
FROM FILE = 'C:\temp\TDECert.cer'
WITH PRIVATE KEY (FILE = 'C:\temp\TDECertKey.pvk' , 
DECRYPTION BY PASSWORD ='pAssW0rD')
GO

but i get :
Msg 15581, Level 16, State 1, Line 1

Please create a master key in the database or open the master key in the session before performing this operation.

to resolve this i try to open the master key:

OPEN MASTER KEY DECRYPTION BY PASSWORD ='DB-PaSSw0rD'
ALTER MASTER KEY ADD ENCRYPTION BY SERVICE MASTER KEY

but i get :
Cannot find the symmetric key 'master key', because it does not exist or you do not have permission.

then to resolve this second issue i try to grant it access:

GRANT CONTROL ON CERTIFICATE :: TDECERT To Administrator

but i get :
Cannot find the certificate 'TDECERT', because it does not exist or you do not have permission.

thanks in advance for ur time

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

请恋爱 2024-12-06 21:11:22

问题解决了

我所要做的就是添加

使用大师

以前

CREATE CERTIFICATE TDECERT
FROM FILE = 'C:\temp\TDECert.cer'
WITH PRIVATE KEY (FILE = 'C:\temp\TDECertKey.pvk' , 
DECRYPTION BY PASSWORD ='pAssW0rD')
GO

,不需要任何其他东西

那么简单!

problem solved

all i had to do is add

USE master

before

CREATE CERTIFICATE TDECERT
FROM FILE = 'C:\temp\TDECert.cer'
WITH PRIVATE KEY (FILE = 'C:\temp\TDECertKey.pvk' , 
DECRYPTION BY PASSWORD ='pAssW0rD')
GO

and didnt need anything else

that easy!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文