Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
472 views
in Technique[技术] by (71.8m points)

sql server 2008 - having problems trying to restore encrypted database

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:empTDECert.cer'
WITH PRIVATE KEY (FILE = 'C:empTDECertKey.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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

problem solved

all i had to do is add

USE master

before

CREATE CERTIFICATE TDECERT
FROM FILE = 'C:empTDECert.cer'
WITH PRIVATE KEY (FILE = 'C:empTDECertKey.pvk' , 
DECRYPTION BY PASSWORD ='pAssW0rD')
GO

and didnt need anything else

that easy!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...