How To Restore A SQL Server Database Master Key On A New Server



TODO:

Have you ever wanted to backup your database master key and move it to a new server?

 

SOLUTION:

--Step 1 -- Backup file
OPEN MASTER KEY DECRYPTION BY PASSWORD 'my password'
     BACKUP MASTER KEY TO FILE = 'c:\myfile' ENCRYPTION BY PASSWORD ='mypassword'

--Step 2 -- Restore file
USE myDatabase
GO
RESTORE MASTER KEY FROM FILE 'my file'

     DECRYPTION BY PASSWORD = 'mypassword'
     ENCRYPTION BY PASSWORD = 'mypassword'
     FORCE;
GO
 

NOTES:

You may not need the 'FORCE' option, read up on what it does and decide accordingly.



Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading