Recently I had a situation where no one knows any level of credentials to SQL a Server instance. The instance I tried was a SQL Server 2008. By default SQL Server 2008 does not provide admin access to built in Windows local admin group.
I was able to get access to it by following below steps;
- Stop SQL Server service using SQL Server configuration Manager.
- Right click on SQL Server service and get properties.
- In Log On tab, use This account option to provide a windows domain account credentials which you already know. I my case I provided my credentials for the specific domain.
- Use Advanced tab to add “-m;” startup parameter to the beginning of the parameter list. The –m startup parameter is use to start SQL Server service in single user mode.
- Click on Apply and then Ok.
- Start SQL Server service.
- Open CMD shell in administrator mode and type the following sqlcmd statement; This will test the access to the server and if it successful, it returns the SQL Server name. This is just a verification.
- sqlcmd -E -S <server name> -q "select @@servername"
- Use the below sqlcmd statement to create a new user called “recovery”.
- CREATE LOGIN recovery WITH PASSWORD = '1qaz2wsx@'
- Use the below sqlcmd statement to grant admin privilege to the user we just created.
- SP_ADDSRVROLEMEMBER 'recovery',SYSADMIN
- Stop the SQL Server service using Configuration Manager.
- Get SQL Server service properties and remove the startup parameter “-m” and click Ok.
- Start the SQL Server service.
- Open SSMS and try to connect to the server using the user name and password we created in above steps.
Hope this helps. Cheers!
Reference:
Have you tried to use PSExec to get access? I can't always shutdown the server to try to get access. If the system user has SA access (and I think that was default until SQL Server 2012) then you can use it to gain access. And you need to be a local admin on the box.
ReplyDeleteYou can get PSExec here https://technet.microsoft.com/en-us/sysinternals/bb842062.aspx
This is the command you would use, you will need to update the path to ssms.exe - PsExec -s -i "D:\MSSQL2K8 (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe"
Thanks!
David
This has worked for me about 75% of the time.