reset sql server express sa password

sql server 2005 express edition does not supplied enterprise manager , and in some case you have to use sa a to  connect to sql server express. and here is the solution.

in default installation , authorization method can't be set and the default authorize method is trusted connection with your windows account.

you need some steps to use sa and chang its password , lets go:

first , open your registry , changing the authorize method with mixed way which can be find in registry , (open run >regedit ) , find loginMode key under HKLM/software/microsoft/.../MSSQL/..  ,change it's value from 1 to 2

restart the sql express service ,and this is important


second , in command prompt , direct to you sql server folder : (like c:\program files\microsoft sqlserver express\bin) , and then type

c:\program files\microsoft sqlserver express\bin> sqlcmd -E -S .\SQLEXPRESS
and then return the >prompt
and then type the follows commands
>sp_password @new='your_sa_pass',@loginame='sa'
>go
>alter login sa enable
>go
>alter login sa with password='your_sa_pass' unlock
>go
>exit


if there is no error occurred , your sql server express password has been changed

so the last step is to test the sa account

osql -U sa -S .\SQLEXPRESS
and then enter your new sa password

note: .\sqlexpress can be replace with your computer name

good luck
原文地址:https://www.cnblogs.com/guojin705/p/1800777.html