SQL Server 2005: How to Reset a Forgotten Password for the sa Account

Contributor Icon Contributed by Rob Rogers  
Tag Icon Tagged: Database  

If you’ve forgotten the sa password for your SQL server, you are probably in a panic. Fear not, for you can reset the password and once again have access to the powers of the sa account by using the query window in the Management Studio.

1. Open the SQL Server Management Studio.

2. Open a New Query.

3. Copy, paste, and execute the following:

GO
ALTER LOGIN [sa] WITH DEFAULT_DATABASE=[master]
GO
USE [master]
GO
ALTER LOGIN [sa] WITH PASSWORD=N'NewPassword' MUST_CHANGE
GO

where NewPassword is the password you wish to use for the sa account.

You can now breathe easier, and once again access the sa account. Whew!

 

15 Comments -


  1. João Cavaleiro said on December 24, 2008

    Great! This should be useful in the future.. or not! Maybe when i’m 70 years old ;)

  2. Sathish said on January 20, 2009

    It’s a useful Tip. It helped me to reset the password. Thank you.

  3. vijay said on May 22, 2009

    Its very useful for me.

  4. Anonymous said on July 30, 2009

    thanks budy
    i seached something else but i got beter than that

  5. Jay said on December 30, 2009

    I have used the software —Password Genius can solve this problem easily. It can find out all passwords which you have logged in with your computer. I would recommend you to try it.
    They promise no-hassle refund if you cannot get your work done.
    Check this out:
    http://www.password-genius.com/how-to/how-to-find-out-my-lost-password.html

  6. Anonymous said on June 17, 2010

    Thanq very much…

    I got success with this solution ..
    GO
    ALTER LOGIN [sa] WITH DEFAULT_DATABASE=[master]
    GO
    USE [master]
    GO
    ALTER LOGIN [sa] WITH PASSWORD=N’NewPassword’ MUST_CHANGE
    GO

    actually i am facing problem like when i login with Sql Server Authentication..it is not accepting the password which i set it for ’sa’ (Even it is correct password)..it is giving me Error: 18456, Severity: 14, State: 8 ..to resolve this i opened Sql Server management studio in Windows Authentication mode and i ran the above script to re-set the password ..now i can able to connect with new password..

    Thanks & Regards
    Suresh.Vadlamudi

  7. Shirantha said on July 26, 2010

    Thanks dude..

  8. Shockvolt said on July 27, 2010

    I guess this only works if the Built-in Admins exist?

  9. Harshavardhan said on August 30, 2010

    GO
    ALTER LOGIN [GOPINATH-PCINFLOWSQL] WITH DEFAULT_DATABASE=[master]
    GO
    USE [master]
    GO
    ALTER LOGIN [GOPINATH-PCINFLOWSQL] WITH PASSWORD=N’abc123′ MUST_CHANGE
    GO

    after executing the above query, am getting the error as below:

    Cannot alter the login ‘GOPINATH-PCINFLOWSQL’, because it does not exist or you do not have permission.

  10. Anil Kumar Sahoo said on December 1, 2010

    I have accidentally disabled the sysadmin role for BUILTIN/Administrator.Now I am not able to get it to the previous state.I cannot also login to sa.Can anyone provide some solution???

  11. Jamil said on April 30, 2011

    Great very useful…….

  12. PTG said on May 17, 2011

    Beautiful
    it solved my problem
    hey i liked it a lotttt
    thxxxx dude 

  13. Vikas said on July 6, 2011

    yes it works thanx dude

  14. Jayant said on August 5, 2011

    Really Amazing, better one.. Thanks Buddy

  15. Spark Ms said on August 18, 2011

    The above script is excellent. Thanks dear.

 

RSS feed for comments on this post. TrackBack URL

Leave a comment -