How to recover sysadmin access to SQL Server 2005/2008 R2 when sa password is lost
- Open the SQL Server Configuration Manager tool
- Navigate to SQL Server Services and Stop the SQL Server Instance that needs a sa password reset
- Right click the on the instance/service and select properties.
- Go to the “Advanced” tab, and in the Properties text box add “;–m” to the end of the list in the “Startup parameters” option
Note! – Please make sure there is no space between “;” and “-m”. In the SQL Server ERRORLOG, there should be an entry that says “SQL Server started in single-user mode.”
- Click the “OK” button and restart the SQL Server Instance
When the SQL Server Instance starts in single-user mode, you can use the Windows Administrator account to connect to SQL Server using the sqlcmd utility and Windows authentication.
Connect to SQL Server using sqlcmd: sqlcmd –S SERVER1\SQLExpress
The following example adds the account “John” in the “EXAMPLE” domain to the SQL Server “sysadmin” role:
EXEC sp_addsrvrolemember ‘EXAMPLE\John, ‘sysadmin’;
Note! Once the sysadmin access has been recovered, remove the “;-m” from the startup parameters using the Configuration Manager and restart the SQL Server Instance