How to reset a password for the sa user of a Microsoft SQL Server instance?
To change a password for the sa user use any of these tools:
- osql utility in a command prompt
- Microsoft SQL Management Studio
- Plesk interface (if Microsoft SQL Server instance is registered in Plesk)
Using osql utility in a command prompt
Start a command prompt as an Administrator and list all Microsoft SQL Server instances:
C:\> OSQL -L
Note: AS stated by Microsofr here, due to the nature of broadcasting on networks, osql may not receive a timely response from all servers. Therefore, the list of servers returned may vary for each invocation of this option. If the command does not display any server, try to execute it another time.
In the command below, specify a Microsoft SQL Server instance for which you want to reset a password and replace ***** with your new password. Once done, run the command:
C:\> osql -S "WIN-TVSNFL1C14U\MSSQLSERVER2017" -E -Q "exec sp_password NULL,'*****','sa'"
For a remote Microsoft SQL Server instance, use its remote server name or IP address:
C:\> osql -S "SERVERNAME or IP ADDRESS\INSTANCE_NAME" -E -Q "exec sp_password NULL,'*****','sa'"
Using Microsoft SQL Management Studio
Download and install SQL Server Management Studio on your Windows Server.
Once installed, start Microsoft SQL Management Studio. To do this, run the command below in a command prompt:
Select Microsoft SQL Server instance for which you want to reset a password from the drop-down list and connect using Windows Authentication.
In the Object Explorer, expand Security > Logins > right-click on sa to open its Properties.
In the Properties window, set a new password for sa and click OK to apply the changes.
If Windows administrator does not have permissions to reset a sa user password, refer to the instructions from this Microsoft article:
Using Plesk interface (if Microsoft SQL Server instance is registered in Plesk)
Follow these steps if Microsoft SQL Server instance is registered in Plesk.
In Plesk, go to Tools & Settings > Database Servers.
Click on a hostname of a Microsoft SQL Server instance, password for which you wish to change.
Click Change Password.
Specify a new password and click OK.