Share via


How to: Restore a Database Master Key

This topic describes how to restore a database master key from backups.

To restore a database master key

  1. In SQL Server Management Studio, connect to the database to which you wish to restore the database master key.

  2. Copy the backed-up key to a local NTFS directory. The directory should be protected with highly restrictive ACLs.

  3. In Query Editor, execute the following Transact-SQL command: RESTORE MASTER KEY FROM FILE = '<complete path and filename>' DECRYPTION BY PASSWORD = '<password1>' ENCRYPTION BY PASSWORD = '<password2>' ; GO 

    Where password1 is the password that was used to encrypt the key on the backup medium, and password2 is the password with which to encrypt a copy of the key in the database.