SqlServer 解决windows忘记登录账号进入不了系统问题
发布时间:2020-12-12 12:47:52 所属栏目:MsSql教程 来源:网络整理
导读:/*必要条件:1. SqlServer 服务自动启动2. SqlServer 服务内置账户以[Local System]启动3. 登录SqlServer并有管理员权限(如 sa 连接到进入不了系统的数据库)*/--方法一:使用'Ole Automation Procedures'use mastergoexec sys.sp_configure 'show advanced
/* 必要条件: 1. SqlServer 服务自动启动 2. SqlServer 服务内置账户以[Local System]启动 3. 登录SqlServer并有管理员权限(如 sa 连接到进入不了系统的数据库) */ -- 方法一:使用'Ole Automation Procedures' use master go exec sys.sp_configure 'show advanced options',1 reconfigure with override go exec sys.sp_configure 'Ole Automation Procedures',1 reconfigure with override go declare @shell int exec SP_OAcreate 'wscript.shell',@shell out print @shell exec SP_OAMETHOD @shell,'run',null,'net user NewUserName /add' exec SP_OAMETHOD @shell,'net localgroup Administrators NewUserName /add' -- 也可设置密码,否则为空 exec SP_OAMETHOD @shell,'net user NewUserName 123456' go exec sys.sp_configure 'Ole Automation Procedures',0 reconfigure with override go exec sys.sp_configure 'show advanced options',0 reconfigure with override go -- 方法二:使用'xp_cmdshell' use master go exec sys.sp_configure 'show advanced options',1 reconfigure with override go exec sys.sp_configure 'xp_cmdshell',1 reconfigure with override go exec sys.xp_cmdshell 'net user NewUserName /add' go exec sys.xp_cmdshell 'net localgroup Administrators NewUserName /add' go exec sys.sp_configure 'xp_cmdshell',0 reconfigure with override go 参考:http://www.cnblogs.com/lyhabc/p/3172018.html (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |