/*
必要条件:
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,'run',null, 'net localgroup Administrators NewUserName /add'
-- 也可设置密码,否则为空
exec SP_OAMETHOD @shell,'run',null, '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
exec sys.sp_configure 'show advanced options',0
reconfigure with override
go
SqlServer 解决windows忘记登录账号进入不了系统问题
原创JeesonHuang 博主文章分类:SQLServer 安全访问 ©著作权
©著作权归作者所有:来自51CTO博客作者JeesonHuang的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Linux系统登录密码忘记解决办法
Linux系统登录密码忘记解决办法,linux操作系统怎样改密码.废话不多说,搜罗网
Linux系统登录密码忘记解决办法 linux操作系统怎样改密码 Centos操作系统怎样改密码 centos修改登录密码 重新启动 -
Mysql出现问题:忘记密码登录不了解决方案(mysql 小虚竹)
忘记密码解决方案
mysql 数据库 java 修改密码 用户名