How to Change SQL Server sa User’s Password

Problem:

You are a Windows Administrator and you can log in SQL server instance. However you cannot access databases.
You want to log in the SQL server instance under sa user but you forget the sa user’s password.
You cannot the sa user’s password using SQL Server Management Studio.

Solution:

1. Open cmd.exe and execute commands below. Replace MSSQL$SQLEXPRESS with your SQL service name and localhost\SQLEXPRESS with your SQL instance.

net stop MSSQL$SQLEXPRESS
net start MSSQL$SQLEXPRESS /m"SQLCMD"
sqlcmd -S localhost\SQLEXPRESS

2. Type and press Enter for each line below.

ALTER LOGIN [sa] WITH DEFAULT_DATABASE=[master]
GO
USE [master]
GO
ALTER LOGIN [sa] WITH PASSWORD=N'Password@1234'
GO
exit

3. Open cmd.exe and execute commands below.

net stop MSSQL$SQLEXPRESS
net start MSSQL$SQLEXPRESS

4. Open SQL Server Management Studio and log in the SQL server using the sa account.