Created
May 7, 2023 11:30
-
-
Save joe-oli/aaf596fcdaaf529aaa590499eb56a047 to your computer and use it in GitHub Desktop.
Recover SQL Server 'sa' password
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#1 Change the DB to single-user mode; | |
e.g. in SQL Configuration Manager, SQL Server services / <Your Server> / Properties / Startup Parameters | |
-f (Add, Apply) | |
RESTART (or stop, start) | |
#2 | |
C:\Users\Administrator>SQLCMD -H $localhost | |
1> CREATE LOGIN newSA WITH PASSWORD = 'Pass@123' | |
2> go | |
1> ALTER SERVER ROLE sysadmin ADD MEMBER newSA | |
2> go | |
#3 change to multi-user mode (i.e. remove -f parameter) | |
RESTART (or stop, start) | |
Then, you should be able to login as newSA in SSMS, and reset the pwd for 'sa' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment