You have Admin rights to the machine, but you set up Microsoft SQL Server as SQL only login with SA, but you’ve forgotten your password. Here’s the dead easy way to reset this, including adding the Admin account and setting it for dual authentication.
Note: due to lots of machine names, etc, I’m going to use any pictures to reduce any security issues.
I did this for MSSQL 2008 R2, but it should work just about everywhere.
On the desktop
- Logon as Administrator (local or network)
- Stop the SQL Server
- Open Command as Admin
- You will need the path to that SQL instance. I open Explorer, find it, then copy the path. It should be something like this:
C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Binn
- In CMD, CD to that directory, then type (don’t forget the period – case doesn’t matter):
.\SQLServr.exe -m
- You need to keep the CMD window open as SQL is now running in that single user session. If you close it accidentally you have to restart this process.
- Start SQL Management Studio.
- Connect to your SQL instance
- Go to security > logins > sa > Properties
- Click Status and make sure you’re not locked out. If you are, you need to uncheck “Login is locked out”, click General and re-enter or change the sa password. Hit Ok and close out of that.
- If you’re switching to/from multi auth mode
- In SMS, right click on the server instance > properties
- Click on security
- Select your authentication mode
- Don’t forget to add your Windows admin user under Security!
- Close SMS
- Switch to the open CMD and press CTRL-C. For some reason I have to do this a couple times. Answer Yes to stop the instance.
- Start SQL and then connect using SMS
- Done!