sql2005 如何禁用xp_cmdshell

来源:百度知道 编辑:UC知道 时间:2024/05/24 18:14:15
网上很多文章都说执行下面的命令来保证SQL的安全

exec sp_dropextendedproc 'xp_cmdshell'[删除此项扩展后,将无法远程连接数据库]
exec sp_dropextendedproc 'xp_dirtree'[删除此项扩展后,将无法新建或附加数据库]
exec sp_dropextendedproc 'xp_enumgroups'
………
………
但我是新手,不太会用SQL,我指在“系统数据库”上,然后“新建查询”,执行每一行命令,试了好多次都不会执行,都提示如下:
消息 3701,级别 11,状态 5,过程 sp_dropextendedproc,第 16 行
无法对 过程 'xp_cmdshell' 执行 删除,因为它不存在,或者您没有所需的权限。

这是怎么回事呢?

请高手指点一下,最好是详细的说说点击哪里来执行这些命令,我只知道“查询”那时能输入这种命令。新手,实在是无奈。

在查询分析器里执行

---启用
-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1
GO
-- To update the currently configured value for advanced options.
RECONFIGURE
GO
-- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 1
GO
-- To update the currently configured value for this feature.
RECONFIGURE
GO

---------------禁用
-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1
GO
-- To update the currently configured value for advanced options.
RECONFIGURE
GO
-- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 0
GO
-- To update the currently configured value for this feature.
RECONFIGURE
GO

你不能删除这些系统存储过程。
可以限制数据库用户使用这些存储过程即可