11-11-2026, 09:20 AM
Yes its needed.
1. Master key migration: The Database Master Key is stored inside the database, so the backup contains it. SQL Server also protects it with the old server's Service Master Key, which is not in the backup. After a restore to another server, the key has to be opened with its password and re-encrypted under the new server's key
We can use below cmdlets to change the DMK Password.
2. Set-RDEnvironmentMasterKeyPassword -DatabaseMasterKeyPassword "MyStrongPassword!"
Once Database is restored, Re-link the encryption key to the new server
This step is important. Do it even if things seem to be working.
```sql
USE [YourDatabaseName];
GO
OPEN MASTER KEY DECRYPTION BY PASSWORD = 'MyStrongPassword!';
ALTER MASTER KEY DROP ENCRYPTION BY SERVICE MASTER KEY;
ALTER MASTER KEY ADD ENCRYPTION BY SERVICE MASTER KEY;
CLOSE MASTER KEY;
GO
```
If the `DROP` line reports that there is no such encryption, simply ignore that message and continue with the `ADD` line.
This command is safe to run even if nothing was broken. It does no harm.
On an Availability Group / cluster: run this on the primary replica. The change travels with the database to the secondaries.
1. Master key migration: The Database Master Key is stored inside the database, so the backup contains it. SQL Server also protects it with the old server's Service Master Key, which is not in the backup. After a restore to another server, the key has to be opened with its password and re-encrypted under the new server's key
We can use below cmdlets to change the DMK Password.
2. Set-RDEnvironmentMasterKeyPassword -DatabaseMasterKeyPassword "MyStrongPassword!"
Once Database is restored, Re-link the encryption key to the new server
This step is important. Do it even if things seem to be working.
```sql
USE [YourDatabaseName];
GO
OPEN MASTER KEY DECRYPTION BY PASSWORD = 'MyStrongPassword!';
ALTER MASTER KEY DROP ENCRYPTION BY SERVICE MASTER KEY;
ALTER MASTER KEY ADD ENCRYPTION BY SERVICE MASTER KEY;
CLOSE MASTER KEY;
GO
```
If the `DROP` line reports that there is no such encryption, simply ignore that message and continue with the `ADD` line.
This command is safe to run even if nothing was broken. It does no harm.
On an Availability Group / cluster: run this on the primary replica. The change travels with the database to the secondaries.
Thank You,
Pavan
Pavan

