SqlServer2008 / SqlServer2012 disable windows login, sa forget your password or login password expires how

Run as administrator cmd

1, under cmd stop SqlServer services, net stop mssqlserver;

2, a new windows account test, adding administrators group, the grant administrator privileges;

3, the user switches to the test;

4, run as administrator cmd, command execution,

5. Do not close the command window on the map, re-run a cmd window as an administrator, execute sqlcmd -id: \ 1.sql; sql script as follows:

the sp_configure 'Show advanced Options',. 1;
the GO
the RECONFIGURE;
the GO
. EXEC [SYS] [the sp_configure] @configname = 'the xp_cmdshell', - VARCHAR (35)
@configvalue. 1 = - int
the RECONFIGURE the override the WITH


- modifying the registry, modify authentication for mixed authentication mode
the USE [Master]
GO
EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE ', N'Software \ in the Microsoft \ the MSSQLServer \ the MSSQLServer', N'LoginMode ', REG_DWORD, 2
GO

- create a login
cREATE LOGIN [ machine name \ the Test] the FROM WINDOWS;
GO

- privileges granted to the login name is of the sysadmin
the USE Master
GO
. EXEC [SYS] [sp_addsrvrolemember] @loginame = ' machine name \ the Test', - sysname
@rolename = of the sysadmin - sysname

--关闭xp_cmdshell功能
EXEC [sys].[sp_configure] @configname = 'xp_cmdshell', -- varchar(35)
@configvalue = 0 -- int
RECONFIGURE WITH override

 

6, turn off all cmd window, restart the service SqlServer

Open SqlServerManagementStudio, Windows authentication to log on, you can log in successfully, the sa password change can be properly used

 

See: https: //blog.csdn.net/QQ38397892/article/details/84454200

Guess you like

Origin www.cnblogs.com/seer/p/11233184.html