sql studio express 2005 lost sa password issue
I have a problem, I'm using windows 7 with MS SQL Server Management Studio Express 2005 althoug开发者_JAVA技巧h I've lost my administrator/ sa password. Is there a command I can use to reset the password, without the old one?
I can login using windows authenication.
many thanks, James
Login to the SQL Server computer as the Administrator of that computer. Open Query Analyzer and connect to SQL Server using Windows NT authentication. Run sp_password as shown below to reset the sa password:
sp_password @new = 'will_never_forget_again', @loginame = 'sa'
EDIT:
This is unexpected, as you were able to get in to detach a db, so you must
have some privileges. The message you got:
... is a response to the sp_password
command. So when you say you tried to
reconnect with 'sa', can you tell us how you did that?
Also, when using the SQLCMD tool, you have to type GO to execute a command:
SP_PASSWORD @NEW = 'my_password', @loginame = 'sa'
GO
Then you need to exit before you try to reconnect.
Try getting in again, and seeing who you are. So after connecting:
C:\sqlcmd -E -d master
Please run this:
SELECT suser_sname(), user_name()
GO
Also, run this after you obtain your user name and enter your new password per my original answer:
ALTER LOGIN sa ENABLE
GO
In the object explorer, go to Security-> Logins and click on preferences for the "sa"-account. There you can reset the password
Because you can login using your windows authentication then it's pretty easy. what you need is just
- login to your management studio,
- on the tree view, expand "security" folder, and also expand the "Logins" folder,
- right click on "sa"
- change the password. done
精彩评论