SQL SERVER 2008 使用TDE加密和解密
SQL SERVER 2008 加密和解密,这样的文件在互联网上不胜枚举,本文的寓意还是一样,一为记录,二可以为开发者提供在实现过程中的注意事项。
TDE: Transparent data encryption is the new database-level encryption feature introduced in SQL Server 2008
加密(详细点击)
- 1. If it does not already exist, create a database master key (DMK) for the master database. Ensure that the database master key is encrypted by the service master key (SMK).
- CREATE MASTER KEY ENCRYPTION BY PASSWORD = ‘some password’;
- 2. Either create or designate an existing certificate for use as the database encryption key (DEK) protector. For the best security, it is recommended that you create a new certificate whose only function is to protect the DEK. Ensure that this certificate is protected by the DMK.
- CREATE CERTIFICATE tdeCert WITH SUBJECT = ‘TDE Certificate’;
- 3. Create a backup of the certificate with the private key and store it in a secure location. (Note that the private key is stored in a separate file—be sure to keep both files). Be sure to maintain backups of the certificate as data loss may occur otherwise.
- BACKUP CERTIFICATE tdeCert TO FILE = ‘path_to_file’
- WITH PRIVATE KEY (
- FILE = ‘path_to_private_key_file’,
- ENCRYPTION BY PASSWORD = ‘cert password’);
- 4. Optionally, enable SSL on the server to protect data in transit.
- Perform the following steps in the user database. These require CONTROL permissions on the database.
- 5. Create the database encryption key (DEK) encrypted with the certificate designated from step 2 above. This certificate is referenced as a server certificate to distinguish it from other certificates that may be stored in the user database.
- CREATE DATABASE ENCRYPTION KEY
- WITH ALGORITHM = AES_256
- ENCRYPTION BY SERVER CERTIFICATE tdeCert
- 6. Enable TDE. This command starts a background thread (referred to as the encryption scan), which runs asynchronously.
- ALTER DATABASE myDatabase SET ENCRYPTION ON
简而言之,就是先创建自己的Master key, 然后创建CERTIFICATE证书,然后备份证书,接着关联Master Key 和CERTIFICATE,然后就是设置数据库SET ENCRYPTION ON.
按照步骤下来,你就可以利用下面的这段话来看,是否加密成功。当然,你也可以一开始就去先做判断。
- ---查看db_name是否加密,------------
- ---- is_encrypted=1表示加密---------
- ---- is_encrypted=0表示未加密-------
- SELECT is_encrypted FROM sys.databases
- WHERE name ='db_name'
解密:
- ALTER DATABASE db_name;
- SET ENCRYPTION OFF;
- GO
- /* Wait for decryption operation to complete, look for a
- value of 1 in the query below. */
- SELECT encryption_state
- FROM sys.dm_database_encryption_keys;
- GO
- USE db_name;
- GO
- DROP DATABASE ENCRYPTION KEY;
- GO
在删除Master key的时候,首先要设置SET ENCRYPTION OFF,然后使用DROP DATABASE ENCRYPTION KEY删除,如果数据库的数据或是结构有变化的话,SQL Management Studio会提示让你去备份数据库日志文件Backup log AdventureWorks2012 set disk="物理地址"。
OK
完成之后,在SQL Management Stud中测试时,无论附加还是还原,需要注意的是,这里如果有了3241,我们仍然可以使用SQL Script的方式进行测试。
SQL SERVER 2008 使用TDE加密和解密的更多相关文章
- SQL Server 2008, 2008 R2, 2012 and 2014 完全支持TLS1.2加密传输
SQL Server 2008, 2008 R2, 2012 and 2014 完全支持TLS1.2加密传输 微软高兴地宣布所有主流SQL Server客户端驱动和SQL Server发行版已经支持T ...
- 在SQL Server 2008中执行透明数据加密
问题 安全是任何公司的一个主要考量.数据库备份容易被偷并被恢复到另一个SQL Server实例上.当我们浏览SQL Server 2008的新特性时,我们对一个叫做透明数据加密的特性很感兴趣,我们可以 ...
- SQL Server 2008连接字符串写法大全
一..NET Framework Data Provider for SQL Server 类型:.NET Framework类库使用:System.Data.SqlClient.SqlConnect ...
- SQL Server 2008连接字符串写法大全{转}
一..NET Framework Data Provider for SQL Server 类型:.NET Framework类库使用:System.Data.SqlClient.SqlConnect ...
- SQL Server 2008连接字符串写法大全(摘自网络)
一..NET Framework Data Provider for SQL Server 类型:.NET Framework类库使用:System.Data.SqlClient.SqlConnect ...
- 《SQL Server 2008从入门到精通》--20180716
1.锁 当多个用户同时对同一个数据进行修改时会产生并发问题,使用事务就可以解决这个问题.但是为了防止其他用户修改另一个还没完成的事务中的数据,就需要在事务中用到锁. SQL Server 2008提供 ...
- SQL Server 2008安全加固手册
1.身份鉴别 1.1避免使用空密码和弱口令 要求:应对登录操作系统和数据库系统的用户进行身份标识和鉴别. 目的:操作系统和数据库系统管理用户身份鉴别信息应具有不易被冒用的特点,口令应有复杂度要求并定期 ...
- 利用SQL Server 2008 R2创建自动备份计划
本文主要利用SQL Server 2008 R2自带的"维护计划"创建一个自动备份数据的任务. 首先,启动 Sql Management studio,确保"SQL Se ...
- SQL Server 2008 阻止保存要求重新创建表的更改问题的设置方法
不是很理解为什么在2008中会加入阻止保存要求重新创建表的更改这个选项.症状表现为修改表结构的时候会"阻止"你.而且我遇到的情况是居然有的时候阻止你,有的时候不阻止你,摸不到头脑. ...
随机推荐
- invoke-command
远程执行命令: invoke-command -ComputerName $server -Credential $cred -ScriptBlock{param($server,$UserName, ...
- time_t和struct tm之间的转换
time_t到struct tm的转换: #include <time.h> struct tm *localtime(const time_t *timep); struct tm到ti ...
- celery expires 让celery任务具有时效性
起因:有的时候.我们希望任务具有时效性.比方定时每5分钟去抓取某个状态,由于celery队列中的任务可能非常多,等到这个任务被运行时.已经超过了5分钟,那么这个任务的运行已经没有意义.由于下一次抓取已 ...
- Android记录6--ViewPage+Fragment的使用例子
Android记录6--ViewPage+Fragment的使用例子 2013年9月6日Fragment学习 Fragment这个东西,我到现在才接触到,之前没有用到过,关于Fragment这个东西在 ...
- Andriod:如何卸载模拟器上已经安装的应用程序?
根据学习对HelloWorld进行手术的时候,遇到了一个问题: 就是在修改了布局后,重新链接模拟器时报错: Installing helloworld.apk... Re-installation f ...
- maven跳过单元测试
24.跳过单元测试 <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>mav ...
- centos6 install mplayer(multimedia)
step_1 http://wiki.centos.org/AdditionalResources/Repositories/RPMForge step_2 http://wiki.centos.or ...
- datejs lib
// Get today's date Date.today(); // Add 5 days to today Date.today().add(5).days(); // Get Friday o ...
- python中关于正则表达式四
[] 用来暗示一个字符串集合, 1.在这个集合中:字符串可以被 独特列出,例如[amk]将会匹配'a','m'或者'k'. 2.字符串的范围可以被暗示通过给两个字符串和分开它们用一个'-':例如[ ...
- android开发之应用Crash自动抓取Log_自动保存崩溃日志到本地
http://blog.csdn.net/jason0539/article/details/45602655 应用发生crash之后要查看log,判断问题出在什么地方,可是一旦应用发布出去,就要想办 ...