This article is about how to reset SQL SA password using cmd. Complete step-by-step method is mentioned to change SQL Server SA password from command line method.
Reset SQL SA Password from Command Line – Ultimate Guide
We all know the pain when we forget the simple Windows sign-in password. But what happens when we lost the SQL Server System Administrator password.
Not Less Than a Nightmare. Right?
Most of the time it happens that DBA accidentally performed some operations in Microsoft SQL Server. Due to which, one cannot connect or login to SQL Server Management Studio.
- While deleting the unnecessary login account, admin removes the administrators’ built-in login account.
- Remove the users that have the SYSADMIN server role permission.
- Set a complex password to SA Login account.
No matter you are using the User or System Administrator account to login into SQL Server, if you forgot or lost the password, using command prompt is the best method to reset SA password of SQL Server 2017 / 2016 / 2014 / 2012 / 2008 / 2008 R2 / 2005 / 2000.
Therefore, in this blog, we are going to use some tips & tricks that let you know the process to reset lost SQL SA password from command line. Keep reading to check it out!
Before Recovery, Do This
You can perform the following thing in order to get the SA password of SQL Server, before using the command line procedure.
- Find out the SA password in your hard-drive. It might be possible that you have written the password in a Notepad file or email.
- Contact the Microsoft Product Support Services (PSS).
If you left out the option, then use the command prompt to change the password of SA Login account.
Well-Rounded Approach to Reset SQL SA Password from Command Line
This method can be used when the Windows account is a member of the local administrators group. Else one cannot perform the procedure. In such a situation, you can try SQL Server SA Password Recovery Tool. It only required ‘master.mdf’ file to reset the password of SA as well as User login account without any fail.
Let’s check out steps to change SQL SA Password from Command Line
Step 1:- First of all, use the SQL Server instance with single-user mode. To do this, you need to execute the following command.
SQLServr.Exe -m or SQLServr.exe -f
Step 2:- Once the above command runs successfully. You need to add yourself as Admin. For this, run the following code.
SQLCMD -S -E
Step 3- Afterward, create either a new account or add an existing account in SQL Server instance. and
Create Login ‘Name_of_Login’ with PASSWORD = ‘password’
Step 4:- Now, provide the SYSADMIN server role to the above-created account.
SP_ADDSRVROLEMEMBER ‘Name_of_Login’, ‘SYSADMIN’
Step 5:- After executing the above steps, just stop the SQL Server service and start later on.
That’s all about how to reset SQL SA password from command line without any fail. So, whenever you lost your System Administrator password, try the above one and get your access back.