I've forgotten my sa password and already disabled windows authentication mode.
How can I reset SQL Server sa password with disabled windows authentication
tnx in advance

- 11
- 1
- 1
- 5
5 Answers
I had the same problem. Tried googling it and all the standard solutions didn't work so I had to get creative. Essentially my problem was that the SA account was disabled, also the system was set to only allow login by windows authentication, and finally the administrator account in windows also was not a member of the sysadmin role. So all the normal suggestions kept giving me permission denied errors (because I didn't have permissions to alter what other posts were telling me I should alter).
My solution is documented below, only apply the parts you need:
Stage 1: - Get SSMS working in single user mode
- Open Sql server configuration manager (SSCM)
- Click on SQL Server Services
- Right click on SQL Server (MSSQLSERVER) and click properties
- Click on the advanced tab
- Find "Startup Parameters" and add the following
- "-m;" at the beginning or ";-m" at the end (note the semi-colons but without quotes)
- be careful to not add any white spaces as the parser is very picky
- Press ok
- Right click again and press restart
- If you get any problems with the service not starting, verify step 5.
Stage 2: Part 1: - Enabling SQL Server and Windows Authentication mode
- Start SSMS again.
- This time when SSMS starts it will start in Single user mode which gives you full access.
- Login with the usual windows account as before.
- Right click on the server node (the very first / topmost node) and choose properties.
- Click on Security
- Under "Server authentication" click on "SQL Server and Windows Authentication mode" if its not already selected.
- Click ok
Stage 2: Part 2: - Adding yourself into the sysadmin role
- Click on "Security" and then "Server Roles"
- Right click on "sysadmin" role
- In the window that pops up, click add at the bottom.
- In the window that pops up, click browse
- Find your user and click the checkbox beside the name.
- Click ok - this will return you to window in step 4 which will now have your user(s) in the lower box.
- Click ok - this will return you to the window in step 3 which will add your user(s) to the role members list.
- Click ok. - Congrats, you now have all the rights of the SA user.
Stage 2: Part 3: Altering the SA Password and enabling the account
- Double Click on Security.
- Double Click on Logins.
- Right click on SA and choose properties.
- Change and confirm the password fields (But don't press ok yet).
- Click on the Status tab.
- Click on Enabled.
- Click ok
This is the process for resetting any users password (for a sysadmin). At this stage you should close SSMS.
Stage 3: Restarting SSMS in multi user mode.
- Follow the steps taken in Stage 1 and simply remove the -m;
Stage 4: Trying on your bigger shoes.
At this stage you should be able to enable or disable the SA account from your login and change its password, also you should be able to enable or disable the ability to login with SQL Server authentication. Test these to ensure you have necessary rights.
Notes: Some taught should go into doing this. I feel that a sysadmin account should be the first thing setup once you setup a new SQL server instance.
Some people recommend removing the SA account (Personally, I recommend just putting a really strong password on it). As long as you have an account with sysadmin this is fine but someone must have an account with sysadmin access. This account should not be named Admin or some variant thereof like God for obvious reasons. Also avoid names such as your business name and combinations of either etc.
As regards to enabling or disabling sql server authentication that's a debate I'll leave for the DB admins.
Hope you find this helpful.

- 4,565
- 8
- 46
- 65
-
1This approach was the only one that worked for me. Running SQL Server from the command line wasn't the same as adding the param to the service startup (for me) - that did the trick. You saved me from getting some new grey hairs. Thank you Francis. – PRB Nov 16 '15 at 22:51
-
@PRB - Glad I could help. I had some grey hairs myself figuring this out. People who say delete the SA account to prevent hacking for me is a bit extreme. Disable it for sure, but don't delete. The reason is exactly this. Its not easy to know what other account has SA privileges, and if the other accounts with SA privileges, during regular admin for whatever reason get deleted, you get into a world of trouble. Most times if that happens, you can just re-enable the SA account and setup a new SA account and disable it again (but only if the SA exists). So I never recommend deleting it. – Francis Rodgers Nov 18 '15 at 18:07
New best way: Use PowerShell. Reset-SqlSaPassword allows administrators to regain access to local or remote SQL Servers by either resetting the sa password, adding sysadmin role to existing login, or adding a new login (SQL or Windows) and granting the login sysadmin privileges. Windows administrator access is required.
This is accomplished by stopping the SQL services or SQL Clustered Resource Group, then restarting SQL via the command-line using the /mReset-SqlSaPassword paramter which starts the server in Single-User mode, and only allows Reset-SqlSaPassword to connect.
Once the service is restarted, the following tasks are performed:
Login is added if it doesn't exist
- List item
- Login is enabled
- Login is added to sysadmin role
- Login is unlocked
- If login is a Windows User, an attempt is made to ensure the account exists
- If login is a SQL Login:
- A secure password prompt will appear
- Password policy is set to off
- SQL Server authentication is set to Mixed Mode
In order to make this script as portable as possible, System.Data.SqlClient and Get-WmiObject are used (as opposed to requiring the Failover Cluster Admin tools or SMO). If using this function against a remote SQL Server, ensure WinRM is configured and accessible. If this is not possible, run the script locally. Works on x86 and x64.

- 1,367
- 12
- 14
-
OMG THIS IS SUCH A WONDERFUL SCRIPT! I WISH I COULD UPVOTE YOU ANOTHER 100 TIMES – Ross Presser Jan 30 '18 at 22:23
-
-
@psychodata this is now in the dbatools command Reset-DbaAdmin – Chrissy LeMaire Jun 24 '23 at 09:25
If you lost sa password and dont have windows authentication login,then sa password can be reset by following steps-:
1.Start SQL Server in single user mode.
(a) open sql server configuration manager
(b) Select your instance and click properties,and set -m of -f parameter in
enter image description here startup parameter.
(c) Click ok,and then restart SQL service .
2.Now all the users who are a member of the host’s local administrator group can connect to SQL Server instance and they will gain the privileges of server level role sysadmin which helps us to recover SA password.
3.Run SSMS (Sql Server Management Studio) as administrator,and login by windows authentication.
4.Now select security tab and select logins and find 'sa' user and select properties,and reset desired password.
5.Then again restart SQL SERVER INSTANCE by right clicking on it. enter image description here
6.Now sa password has been reset.
7.Now remove -f or -m parameter from SQL Server Configuration startup parameters.enter image description here
8.Again restart SQL SERVER SERVICE by right clicking on instance in configuration manager.
9.Now you have successfully reset sa password of SQL Server and check it by running SSMS and set SQL Server authentication mode in management studio.

- 31
- 5
Simple steps for SQL Server 2008+, which no longer have Admin group added by default.
From command line (as a Win admin):
net stop MSSQLSERVER
net start MSSQLSERVER /m /f
ssms
Here (in the launched SSMS) you can create additional sysadmins, change the sa password. Then back to the command shell:
net stop MSSQLSERVER
net start MSSQLSERVER

- 1,807
- 20
- 25
Here is a step by step 5 minute video on how to reset the SysAdmin password using either SQL Server Authentication or Windows Authentication
https://www.youtube.com/watch?v=GOvbjo1tlYo
The basic steps is also to start SQL Server in Single User Mode, then adding a new SysAdmin user. The basic steps highlighted in the video is as follows
Start Single User Mode Step by Step
- SQL Server Configuration Manager - Make sure to enable NamedPipes/TCP Locally
- List the Services a. net start b. services.msc
- Stop the Service - net stop [SQL-SERVICENAME]
- Start Single User Mode a) net start [SQL-SERVICENAME] -m"SQLCMD" b) "C:\Program Files\Microsoft SQL Server\MSSQL14.SQL1\MSSQL\Binn\sqlservr.exe" -sSQL1 -m"SQLCMD"
- SQLCMD -S [SQL INSTANCE]
- sqlcmd - Login a) SQL User - CREATE LOGIN [name] WITH PASSWORD='password'; GO b) Windows User - CREATE LOGIN [domainName\login_name] FROM WINDOWS; GO
- sqlcmd a) SP_ADDSRVROLEMEMBER name,'SYSADMIN'; GO b) Confirm - SELECT name FROM syslogins; GO;
- sqlcmd - exit

- 2,983
- 1
- 15
- 12