Gain SYSADMIN access to SQL Server

To Gain SYSADMIN access to SQL Server you need to be local administrator of the server.
The steps are:
Stop the SQL Server Database Service
Open an elevated command prompt and run “SQLServr.Exe –m”
You may need to browse the Binn path of the SQL server installation, usually is: C:Program FilesMicrosoft SQL ServerMSSQL10.MSSQLSERVERMSSQLBinn
Open an other elevated command prompt window and run:
SQLCMD –S . (. is for local server with default instance)
Now you are connected to the SQL Database and you cna start the Query:

/*To add a domain account run:*/
1>CREATE LOGIN [MyDomainMyUser] FROM WINDOWS;
2>ALTER SERVER ROLE sysadmin ADD MEMBER [MyDomainMyUser];
3>GO;
/*To add an SQL account run:*/
1>CREATE LOGIN SQLUser WITH PASSWORD = '************';
2>ALTER SERVER ROLE sysadmin ADD MEMBER SQLUser;
3>GO;
/*To change the sa password run:*/
ALTER LOGIN sa WITH PASSWORD = '************';

 

Finally close both command prompt windows and start the SQL service fom the services mmc.

Share

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.