SQL Server transparent Data encryption

Source: Internet
Author: User

One, the encryption process

(1) Switch to master:

Use master;

(2) Create a master key based on a custom password:
CREATE MASTER KEY Encryption by PASSWORD = ' password ';

(3) Create a master key certificate, subject to any of the fields:
CREATE CERTIFICATE certificate name with SUBJECT = ' test subject ';

(4) switch to the library under which you want to encrypt:

Use user database;

(5) Create a database key based on the encryption algorithm and certificate:
CREATE DATABASE encryption KEY with algorithm = aes_128 encryption by SERVER CERTIFICATE certificate name;

(6) Turn on the encryption state of the library:
ALTER database SET encryption on;

------------------------------------------------------------------

Second, backup and restore

(1) The Backup master key is in the specified directory:
BACKUP MASTER KEY to FILE = ' d:\storedkeys\weifang\masterkey ' encryption by PASSWORD = ' Password '

(2) Backup certificate:
BACKUP CERTIFICATE certificate name to FILE = ' d:\storedcerts\weifang\sdjslcert '; :


(3) Restore master key:

Use master
RESTORE MASTER KEY from FILE = ' D:\storedkeys\weifang\masterkey '
Decryption by PASSWORD = ' Password '
Encryption by PASSWORD = ' password ';

--because I still have the original certificate here, so I will prompt the following information:
--the old and new master keys is identical. No data re-encryption is required.

(4) Restore certificate
CREATE CERTIFICATE Card Title
From FILE = ' D:\storedcerts\sdjslcert '
GO
--Because the certificate already exists, the following information is prompted:
--A Certificate with Name ' MyServerCert2 ' already exists or this certificate already have been added to the database.
It is important to note that certificates are not differentiated according to the title of the certificate. My original certificate name is Myservercert, the certificate created here is named MyServerCert2, but it is a backup from Myservercert, or an error.

SQL Server transparent Data encryption

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.