How to Reset SA Password In SQL Server with Different Methods

Daniel Jones ~ Modified: January 17th, 2024 ~ SQL, SQL Server 2016 ~ 5 Minutes Reading

Problem

In this article we will look at the procedure to Reset SA Password In SQL Server, if the SA password was forgotten or there are no users with administrative rights to MS SQL 2016. We will show how to retrieve the password of the SA account, and, if necessary, provide the necessary Windows account with MSSQL administrator rights.

Solution

Situations when an SA user is lost / forgotten on MS SQL DBMS happen quite often. As a rule, the option of reinstalling SQL and reconnecting the database is not considered, since in this time, the configuration parameters stored in the system master database will be lost.

SQL Server provides much more convenient access recovery functionality. The fact is that members of the local group of administrators of the system on which SQL Server is installed have full authority on a DBMS running in single-user mode.

By running SQL Server in single user mode, you can change the password of the SA account or grant the administrative rights to the desired Windows account.

Note: Recall that starting with SQL Server 2016, the local group of administrators of the system on which SQL Server is installed is not added by default to the sysadmin role on the SQL server.

The procedure for starting SQL Server 2016 in single-user mode and restoring access is as follows (the main condition is that you must have administrator rights on the system on which MSSQL is installed)

Full Guide to Reset SA Password In SQL Server 2016

Step 1: Open Run window by pressing Windows key along with R key. Afterward, you need to write CMD on the text box.

Step 2: To stop SQL instance from running, type net stop MSSQLSERVER command and hit the Enter key

Step 3: Stop  service of the necessary SQL Server instance (in our case the name of the instance MSSQL is SQLEXPRESS ) by typing net stop MSSQL$SQLEXPRESS and press the Enter Key.

Step 4: Open the registry editor (regedit.exe) and go to the parameters section to start the SQL service: HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\ MSSQL$SQLEXPRESS

Step 5: Changing the value ImagePath , adding as an argument sqlservr.exe key « -m ». In our example, we got the following value: “C:\Program Files\Microsoft SQL Server\MSSQL13.SQLEXPRESS\MSSQL\Binn\sqlservr.exe” -m -s SQLEXPRESS

Step 6: We start the SQL Server service: net start MSSQL$SQLEXPRESS

Step 7: SQL is now running in single user mode and allows any member of the local computer administrators group to connect to an instance of SQL Server with sysadmin privileges.

Step 8: Using SQL Server Management Studio, change the SA password or provide the sysadmin role to the required Windows account.

Tip: You can perform this operation from the sqlcmd command line: EXEC sp_addsrvrolemember ‘DOMAIN\Username’, ‘sysadmin’;

It remains only to stop the SQL service, change the ImagePart key value to the original one, removing the “-m” attribute ( “C: \ Program Files \ Microsoft SQL Server \ MSSQL13.SQLEXPRESS \ MSSQL \ Binn \ sqlservr.exe” -sSQLEXPRESS” ) and start SQL Server in normal mode.

Alternate Method to Reset SA Password In SQL Server Within Clicks

In case, you are unable to change SA password in SQL Server with the above solution, then do not worry about it. We have another robust solution named SQL Password Recovery, which helps you in changing the SA password using Master.mdf file in a few simple clicks.

Download Now Purchase Now

For this, you need to stop your SQL server services.

Step 1: Open Services and right-click on SQL Server then Click on Stop SQL Server services

Step 2: Go to the default location of master.mdf file and make a backup copy of both (master.mdf & mastlog.ldf) in another location of your system.

Step 3: Now Download the tool and launch on your machine.

Step 4: Click on the Browse button to load the master.mdf from the default location into the software.

Step 5: After successfully loading the master.mdf, software will scan the file and display the list of usernames created on the Server.

Preview Login Name

Step 6: Click on the User Name for which you want to reset the password and click on Reset Password button
software will again warn you to take backup of master.mdf and mastlog.ldf (Make sure you have taken a backup of both these files).  Now, set a new password for your SA & User Login and click on OK

Reset SA Password

when the password is changed successfully, A message will pop-up. Click OK. Once you have done with the procedure, Go to Services, Right click on SQL server and click on Start to restart the SQL Server Services.
When the process to reset SA password in SQL Server is done, launch SQL Server Management Studio and log in via the new password to verify it.

That’s all about how to reset SA Password in Microsoft SQL Server without any fail.