Friday, January 4, 2013

deleted administrator account


if you forgot the SA password or accidently delete the administrator account where you cant access the sql server
follow the below steps to create an administrator account.

This requires to restart the sql server in single user mode till you create the login with sysadmin access

1.open sql server configuration manager (click on All Programs-->Microsoft SQL Server 2008-->SQL Server configuration manager

image

2.double click on SQL Server --> properties -->advanced.

at the startup Parameters add ;-m at the end.

image

3.restart the SQL Server

4.stop all the services except SQL Server

deleted administrator account

5.right click on cmd tool . select [run as administrator]

image

6. at the cmd prompt type sqlcmd

7. add your own administrator account by copy paste the below

USE [master]
GO
CREATE LOGIN [domain\mylogin] FROM WINDOWS WITH DEFAULT_DATABASE=[master]
GO
EXEC master..sp_addsrvrolemember @loginame = N'domain\mylogin', @rolename = N'sysadmin'
GO

8.open configuration manager --> advanced -->startup parameters - remove the ;-m parameter which you have added at step 2

9.restart the SQL Server

10. restart all the services which have disabled at step 4

No comments:

Post a Comment

Featured Post

SQL Server AWS Migration BCP

stored procedure to generate BCP scritps to migrate the SQL Server database. Developed this stored procedure on my labs to simulate t...

Contributors