首页 > 代码库 > 数据库加密&证书创建
数据库加密&证书创建
以下是用sqlserver给数据库进行加密的脚本,其中当然也包含了证书创建的步骤:
USE master;GO --drop master keyCREATE MASTER KEY ENCRYPTION BY PASSWORD = ‘123456‘; GOBACKUP MASTER KEY TO FILE = ‘D:\SQL1_master.key‘ ENCRYPTION BY PASSWORD = ‘123456‘; GO CREATE CERTIFICATE TDECert WITH SUBJECT = ‘TDE Certificate‘; GOBACKUP CERTIFICATE TDECert TO FILE = ‘D:\SQL1_master.cer‘ WITH PRIVATE KEY ( FILE = ‘D:\SQL1_TDECert.pvk‘, ENCRYPTION BY PASSWORD = ‘123456‘ ); USE TEST; GO CREATE DATABASE ENCRYPTION KEY WITH ALGORITHM = AES_128 ENCRYPTION BY SERVER CERTIFICATE TDECert;GOALTER DATABASE TEST SET ENCRYPTION ON--如果需要还原加密后的数据库文件到另外一台服务器,需要首先还原证书到目标服务器:--目标服务器的master key 可以跟原服务器的不一样USE master; CREATE CERTIFICATE TDECert FROM FILE = ‘D:\SQL1_master.cer‘ WITH PRIVATE KEY ( FILE = ‘D:\SQL1_TDECert.pvk‘, DECRYPTION BY PASSWORD = ‘123456‘ );
数据库加密&证书创建
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。