How to Recover or Reset a Lost SQL Server Password

Last updated on: October 31st, 2026 6 Min Read

Quick Answer

SQL Server stores passwords as hashes, so you usually reset a lost password rather than read it. Sign in with Windows Authentication (or another sysadmin) and reset the login in SSMS, or start SQL Server in single-user mode and run ALTER LOGIN. If both fail, the SoftMagnat SQL Password Recovery Tool can recover the password from the MDF file. The free trial shows only the first two characters.

Locked out of SQL Server? You are not alone. Example: a small company’s only database administrator leaves, nobody knows the sa password, and the accounting database can no longer be managed. This guide shows how to recover or reset a lost SQL password manually, from the simplest method to the most technical, and what to do when they fail.

Why You Can Lose SQL Server Access

  • The sa (system administrator) password was forgotten or never handed over.
  • A former employee’s login was the only sysadmin account.
  • sa was disabled or locked after repeated wrong attempts under the password policy.
  • Your Windows account is not a sysadmin. Since SQL Server 2008, the local Administrators group is not added to the sysadmin role by default.
  • All sysadmin logins were deleted by mistake.

Before You Start

  • Get authorization. Only reset passwords on servers you own or administer. Doing this on someone else’s server is illegal.
  • Back up first. Copy the master database files before making changes.
  • Check the authentication mode. If the server uses Windows Authentication only, SQL logins such as sa cannot connect, even after a reset. Switch to Mixed Mode in Server Properties > Security.

The steps below apply to SQL Server 2012 through SQL Server 2025. Note that SQL Server 2016 left extended support on July 14, 2026, so consider upgrading.

List of Microsoft SQL Server versions and editions

Method 1: Ask Another Sysadmin

Any member of the sysadmin role can reset your password in seconds. Check whether a colleague, an IT partner or a Windows domain admin group still has access before trying anything technical.

Method 2: Reset the Password in SSMS with Windows Authentication

This works if your Windows account is already a sysadmin. Example: you are logged in as the domain admin who installed SQL Server, but nobody remembers the sa password. A reset takes about two minutes.

  1. Open SQL Server Management Studio (SSMS). SSMS 22 is the current release, and older versions use the same steps.
  2. Enter your server name, choose Windows Authentication and click Connect.

Connecting to SQL Server in SSMS with Windows Authentication

  1. In Object Explorer, expand Security > Logins.

Security and Logins folder in SSMS Object Explorer

  1. Right-click sa (or the affected login) and choose Properties.
  2. Enter and confirm a new strong password. If the account is disabled, open the Status page and set Login to Enabled.
  3. Click OK.

Login Properties window to change a SQL Server password

You can do the same in a query window:

ALTER LOGIN sa WITH PASSWORD = 'YourN3w!StrongPassword';
ALTER LOGIN sa ENABLE;

Method 3: Reset the SA Password in Single-User Mode (Command Line)

If no sysadmin account is available, you can still get in as a local Windows administrator on the server. Microsoft documents this as the way to regain access when system administrators are locked out. It needs a short outage, because the service restarts.

  1. Open Command Prompt as administrator.
  2. Stop SQL Server Agent, or it will take the only available connection.
  3. Run the following commands (default instance):
net stop MSSQLSERVER
net start MSSQLSERVER /mSQLCMD
sqlcmd -S . -E

Starting SQL Server in single-user mode from the command prompt

  1. At the 1> prompt, run:
ALTER LOGIN sa WITH PASSWORD = 'YourN3w!StrongPassword';
ALTER LOGIN sa ENABLE;
GO
EXIT

Running ALTER LOGIN in sqlcmd to reset the SA password

  1. Restart the service normally:
net stop MSSQLSERVER
net start MSSQLSERVER

Tips: type SQLCMD in capital letters. For a named instance, use MSSQL$InstanceName and sqlcmd -S .\InstanceName -E. To give your own Windows account access instead, run CREATE LOGIN [DOMAIN\YourName] FROM WINDOWS; and then ALTER SERVER ROLE sysadmin ADD MEMBER [DOMAIN\YourName];.

When Manual Methods Fail: Use SoftMagnat SQL Password Recovery Tool

Manual methods need a working SQL Server service and local admin rights. They are risky for non-experts. Example: the server will not start in single-user mode, or all you have is a copy of the master.mdf file after a migration. A dedicated tool is easier here.

The SoftMagnat SQL Password Recovery Tool works like this:

  1. Select the MDF file.
  2. Choose the user whose password you need.
  3. Click recover. The recovered password appears in the results list.

It also recovers multilingual passwords from MDF files, and it lets you change the recovered password. The free trial is almost the same as the full version, but shows only the first two characters of the password.

Download SoftMagnat SQL Password Recovery Tool

If your real problem is a damaged database rather than a lost password, see SoftMagnat SQL Database Recovery or SQL Server Recovery Manager.

How to Avoid Losing SQL Server Access Again

  • Keep at least two sysadmin accounts, ideally a Windows group.
  • Store the sa password in a company password manager.
  • Leave sa disabled and use named admin accounts.
  • Remove departing staff logins only after confirming other admins exist.
  • Take regular backups and keep SQL Server updated.

Related Reading

Frequently Asked Questions

Can I recover a lost SQL Server SA password?

Usually you reset it instead, because SQL Server stores passwords as hashes. Sign in as another sysadmin, use Windows Authentication, or use single-user mode. If those fail, SoftMagnat SQL Password Recovery Tool can recover SQL passwords from the MDF file.

How do I reset the SA password if I cannot log in?

Log in to the server as a local Windows administrator, stop SQL Server Agent, and start SQL Server in single-user mode with the /mSQLCMD option. Connect with sqlcmd and run ALTER LOGIN sa WITH PASSWORD, then restart the service normally.

Do these manual methods work on SQL Server 2022 and 2025?

Yes. Windows Authentication, SSMS login properties and single-user mode with ALTER LOGIN apply to SQL Server 2012 through 2025. Menu layouts differ slightly between SSMS versions.

How does SoftMagnat SQL Password Recovery Tool recover passwords?

You select the MDF file, choose the user whose password you want to recover, and click recover. The recovered password is then listed in the results. No command-line knowledge is needed.

Can the tool recover multilingual passwords and change them?

Yes. It can recover multilingual passwords from MDF files in a single run, and it also lets you change the recovered password.

Is the trial version of the tool limited?

Yes. The trial works almost like the full version but displays only the first two characters of the recovered password. Buy the full version to see the complete password.

Which SQL Server versions does the tool support?

The tool recovers passwords from Microsoft SQL Server 2000 database files. If you use a newer version such as SQL Server 2019 or 2022, download the free trial and test it on a copy of your master.mdf file first.

Is it legal to recover a SQL Server password?

Yes, if you own the server or are authorized by its owner. Never use password recovery methods or tools on systems you do not have permission to manage.

5/5 - (1 vote)

As a Technical Writer at SoftMagnat Software, I craft precise and straightforward documentation for software users. My goal is to break down technical information into clear, simple content, ensuring users can easily understand and use the products. I focus on creating effective manuals, guides, and tutorials that enhance the overall user experience.