【问题标题】:Enable xp_cmdshell does not work启用 xp_cmdshell 不起作用
【发布时间】:2014-09-25 23:10:32
【问题描述】:

我尝试在 SQL Server 中启用xp_cmdshell。于是我跑了:

EXEC master.dbo.sp_configure 'show advanced options', 1
RECONFIGURE
EXEC master.dbo.sp_configure 'xp_cmdshell', 1
RECONFIGURE 

返回的消息说:

配置选项“显示高级选项”从 1 更改为 1。运行 RECONFIGURE 语句进行安装。

配置选项 'xp_cmdshell' 从 0 更改为 1。运行 RECONFIGURE 语句进行安装。

构面属性显示“XPCmdShellEnabled”

但是,当我执行时

EXEC master..xp_cmdshell 'dir c:'

我收到了错误信息

消息 15281,级别 16,状态 1,过程 xp_cmdshell,第 1 行
SQL Server 阻止了对组件“xp_cmdshell”的过程“sys.xp_cmdshell”的访问,因为该组件作为该服务器安全配置的一部分被关闭。系统管理员可以使用 sp_configure 启用“xp_cmdshell”的使用。有关启用“xp_cmdshell”的详细信息,请参阅 SQL Server 联机丛书中的“表面区域配置”。

我所做的是来自 Microsoft 文档。为什么它不起作用?

【问题讨论】:

  • 您使用的是什么版本的 SQL Server?看起来你做对了,我看不出它没有任何原因。
  • 您好,感谢您的回复。它是 SQL Server 2008 R2。执行 xp_cmdshell 是否需要任何权限?
  • SQL Server 安全性不是我的强项,但我认为您需要CONTROL SERVER 权限。它应该默认授予 sa 和管理员。

标签: sql-server sql-server-2008-r2 xp-cmdshell


【解决方案1】:

让我们试试这个:禁用它,然后重新启用它。

--Disable
Use Master

GO
EXEC master.dbo.sp_configure 'xp_cmdshell', 0
RECONFIGURE WITH OVERRIDE

GO

EXEC master.dbo.sp_configure 'show advanced options', 0
RECONFIGURE WITH OVERRIDE
GO

-- Enable
Use Master
GO
EXEC master.dbo.sp_configure 'show advanced options', 1
RECONFIGURE WITH OVERRIDE
GO

EXEC master.dbo.sp_configure 'xp_cmdshell', 1
RECONFIGURE WITH OVERRIDE
GO

【讨论】:

    【解决方案2】:

    您可以从 SQL Server Management Studio 执行此操作,如下所示:

    1. 右击服务器,选择Facets
    2. 选择构面Surface Area Configuration
    3. 将属性XPCmdShellEnabled 设置为True

    【讨论】:

      猜你喜欢
      • 2020-06-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-06
      • 2014-06-18
      • 2014-12-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多