This guide explains how to find or reset the default sa (system administrator) password for Microsoft SQL Server. The sa account is the built-in superuser for SQL Server, and its default password is often blank or set during installation. You’ll learn where to look for it, how to reset it if you’ve forgotten it, and how to avoid common pitfalls.
What You’ll Need
- Access to the Windows server where SQL Server is installed (or the ability to connect remotely via RDP or SQL Server Management Studio).
- Administrative rights on that Windows machine (to change the service configuration or use single-user mode).
- SQL Server Management Studio (SSMS) or the
sqlcmdcommand-line tool (you can download SSMS for free from Microsoft). - If you’re resetting the password, you’ll need to know the Windows account that has admin privileges on the server.
Step-by-Step
- Check if the sa password was set during installation. When you install SQL Server, the setup wizard asks you to specify a password for the
saaccount. If you chose “Windows Authentication mode” only, the sa account is disabled and has a blank password. If you chose “Mixed Mode,” the password you entered is the current one. Look in your installation logs (usually atC:\Program Files\Microsoft SQL Server\{version}\Setup Bootstrap\Log) for a file namedSummary.txtorErrorlog—these sometimes contain the sa password if you used a scripted install. - Try the default blank password. If the sa account was never explicitly configured, it might have a blank password. Connect using SSMS or
sqlcmdwith the usernamesaand leave the password field empty. If that works, you’re in—but you should immediately set a strong password. - Use SQL Server Configuration Manager to enable sa. If the sa account is disabled, you need to enable it. Open SQL Server Configuration Manager, right-click the SQL Server service instance, and select “Properties.” Go to the “Advanced” tab and set “Startup Parameters” to include
-m(single-user mode). Restart the service. Then connect to SQL Server using Windows Authentication (you must be an admin). Run the following T-SQL to enable sa and set a new password:ALTER LOGIN sa ENABLE; GO ALTER LOGIN sa WITH PASSWORD = 'YourStrongPassword'; GO
After that, remove the
-mstartup parameter and restart the service again. - Reset sa password using single-user mode. If you don’t know the sa password and can’t connect with Windows Auth (e.g., the server is in mixed mode but you’ve lost the admin password), you can start SQL Server in single-user mode from the command line. Stop the SQL Server service, then start it manually with
sqlservr.exe -mfrom the command prompt (run as administrator). Open another command prompt and runsqlcmd -S localhost -Eto connect as an admin. Then execute the sameALTER LOGINstatements to reset the password. After that, stop the manual process and restart the service normally. - Check the error log for the initial password. If you never set a password and the sa account is enabled, the error log might show a default password. Look in the SQL Server error log (usually in
C:\Program Files\Microsoft SQL Server\{instance}\MSSQL\Log) for entries like “sa login succeeded” or “Login failed for user ‘sa'”—sometimes the password is visible in the log if it was set via a script. - If all else fails, reinstall SQL Server. This is the nuclear option. Uninstall SQL Server completely (including all services and data) and reinstall it. During installation, you’ll set a new sa password. This is only recommended if you don’t care about the existing databases or have backups.
Common Mistakes
- Assuming the password is always “sa” or “password”. SQL Server does not have a universal default sa password. It’s either blank or set during installation.
- Forgetting to enable sa. Even if you know the password, the sa account might be disabled. Check the server’s login properties.
- Using single-user mode without stopping the service properly. If you don’t stop the SQL Server service before starting with
-m, you might get errors because the service is already running. - Not removing
-mafter resetting. Leaving single-user mode active means only one user can connect at a time, and it’s a security risk. - Setting a weak password. The sa account has full control over the server. Use a complex password with at least 12 characters, including uppercase, lowercase, numbers, and symbols.
Tips
- Always use Windows Authentication for daily admin tasks. The sa account should be used only when necessary, and its password should be stored securely in a password manager.
- Enable mixed mode only if you need it. If you can stick with Windows Authentication, do so. It’s more secure and avoids the sa password issue entirely.
- Document your sa password. When you set it, write it down and store it in a secure location. This saves you from future headaches.
- Use a strong password policy. SQL Server can enforce password complexity if you enable it in the server properties.
- Test your connection after resetting. Always verify that you can log in with the new password before closing the session.
Troubleshooting
- Cannot connect with sa even after resetting. Make sure the server is in mixed mode. Right-click the server in SSMS, go to Properties > Security, and select “SQL Server and Windows Authentication mode.” Restart the service.
- Single-user mode doesn’t work. Ensure you’re running the command prompt as administrator. Also, check that the
sqlservr.exepath is correct. You might need to run it from the SQL Server installation directory. - Error: “Login failed for user ‘sa'” (Error 18456). This means the password is wrong or the account is disabled. Double-check the password and enable the account.
- Error: “Cannot open user default database.” This can happen if the sa account’s default database is missing or inaccessible. Change the default database to master using
ALTER LOGIN sa WITH DEFAULT_DATABASE = master;. - Forgot the Windows admin password too. You’ll need to reset the Windows password using another admin account or a password reset disk. Then you can proceed with the single-user mode method.
Frequently Asked Questions
Is the default sa password always blank?
No. During installation, you can set a password. If you chose Windows Authentication mode, the sa account is disabled and has a blank password, but it’s not usable until you enable it.
Can I retrieve the sa password if I forgot it?
You cannot retrieve it, but you can reset it using the single-user mode method described above, provided you have administrative access to the Windows server.
Is it safe to use the sa account?
It’s safe if you use a strong password and restrict access. However, it’s better to use Windows Authentication for daily tasks and reserve sa for emergencies.
What if I can’t access the Windows server at all?
You’ll need to contact the person who manages the server or use remote management tools like RDP if you have credentials. Without server access, you cannot reset the sa password.
Does the sa password expire?
By default, SQL Server does not enforce password expiration for the sa account. You can set it manually using ALTER LOGIN sa WITH CHECK_EXPIRATION = ON; if desired.
Can I disable the sa account after resetting?
Yes, if you don’t need it, you can disable it with ALTER LOGIN sa DISABLE;. This improves security, but make sure you have another admin account.
Related
General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.
More in this bed
- Google Desktop Search Widget on Windows 11
- How to Build a Computer Stand (Saturday Workshop)
- Customize Touch Keyboard Themes in Windows 11
- Excel Pivot Table: Change Multiple Field Settings
- WhatsApp: How to Block Unknown Numbers
- How to Exit Vi in Linux: A Simple Guide