SqlServer 关闭数据库的xp_cmdshell命令以防止黑客攻击

  一、关闭和恢复xp_cmdshell命令 

关闭

USE master
EXEC sp_configure 'show advanced options', 1
RECONFIGURE WITH OVERRIDE 
EXEC sp_configure 'xp_cmdshell',0
RECONFIGURE WITH OVERRIDE 
EXEC sp_configure 'show advanced options',0
RECONFIGURE WITH OVERRIDE 

恢复

USE master
EXEC sp_configure 'show advanced options', 1
RECONFIGURE WITH OVERRIDE 
EXEC sp_configure 'xp_cmdshell',1
RECONFIGURE WITH OVERRIDE 
EXEC sp_configure 'show advanced options',0
RECONFIGURE WITH OVERRIDE 

 

      二、收缩数据库事务日志        

     方法一:
     1.企业管理器—数据库—属性—选项—故障还原中'完全'选择为 '简单'
     2.企业管理器—所有任务—收缩数据库—文件—选日志文件—点击确定进行收缩
     3.最后将前面改动的故障还原改回'完全'就可以了

     方法二:
     1.在查询分析器中运行:

 --收缩日志代码,hh为数据库名称
     dump tran hh with no_log
     backup log hh with no_log
     dbcc shrinkdatabase(hh)

  

posted @ 2024-09-05 10:40  张岂逢  阅读(53)  评论(0编辑  收藏  举报