having problems trying to restore encrypted database

匿名 (未验证) 提交于 2019-12-03 01:58:03

问题:

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

回答1:

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!



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!