8

有没有办法在不使用 SQL Server Management Studio 的情况下更改 SQL Server 2008 或 2012 中的授权模式?

4

2 回答 2

15

以下是 Management Studio 将身份验证模式从混合更改为仅 Windows 所做的操作:

EXEC xp_instance_regwrite 
    N'HKEY_LOCAL_MACHINE', 
    N'Software\Microsoft\MSSQLServer\MSSQLServer', 
    N'LoginMode', 
    REG_DWORD, 
    1;

而从 Windows 只回到混合:

EXEC xp_instance_regwrite 
    N'HKEY_LOCAL_MACHINE', 
    N'Software\Microsoft\MSSQLServer\MSSQLServer', 
    N'LoginMode', 
    REG_DWORD, 
    2; -- only difference is right here

您可以从可以连接到 SQL Server 的各种源(例如 SQLCMD、PowerShell、VBScript、C# 等)调用相同的命令。或者您可以直接登录到服务器,导航到该注册表项,然后手动更改值(如 @ marc_s 建议)。

请注意,在所有情况下,您都必须重新启动 SQL Server 才能使更改生效。您可以在重新启动时查看新错误日志中的前几个条目,以验证身份验证模式是否正确。它会说(混合):

date/time    Server    Authentication Mode is MIXED.
于 2012-08-15T16:24:09.703 回答
0

I found out that if you installed your SQL express 32bit (in my case) on 64bit Windows, the reg path has to be HKEY_LOCAL_MACHINE\ SOFTWARE\Wow6432Node\Microsoft\MSSQLServer\MSSQLServer. the change here is the Wow6432Node key.

于 2019-03-19T16:52:06.663 回答