0

I have 2 instances, sqlexpress and mssqlserver. I made fool mistake, I disabled the login account that I used it all of the time to login in mssqlserver using windows authentication. And I don't remember the 'sa' password because never use it to log in.

I have read and practice some tips about this problem, and Connect to SQL Server When System Administrators Are Locked Out but my problem still isn't solved.

So, my questions. Does uninstall then reinstall can give me access again? If yes, which should I uninstall-reinstall? My sql server or ssms? I'm not worried about databases, I just want the access to this instance again for learning.

enter image description here

2
  • 1
    Start the SQL Server in single user mode and re-enable the account: dba.stackexchange.com/questions/101378/…
    – Spörri
    Commented Jan 24, 2017 at 14:19
  • @Spörri it doesn't work, gives me message: is not a valid login or you do not have permission. I have spared so many times for it, this one day, how about my question uninstall?
    – Anti Mafia
    Commented Jan 24, 2017 at 15:32

3 Answers 3

1

So, my questions. Does uninstall then reinstall can give me access again?

Yes, uninstall and reinstall will give you access again

If yes, which should I uninstall-reinstall? My sql server or ssms?

SQL Server

0

Since you're using this instance for learning and don't care about the databases, you might also want to learn troubleshooting. The link from your post is one of the "break glass in case of emergencies" panels. If it didn't work, you really want to figure out why. Else, if this happens to an instance where you care about both the instance and the user databases, you'll be in a pretty rough spot. Is there anything useful in the error log that might hint to what happened?

If you really don't care to investigate, you can uninstall the existing instance and install a new one. That lets you specify the SA password or identify the user account that will be admin (or both). However, this wipes all previous user logins - there is no "re-install" per se with that preserves security principals or other objects that reside in a system database.

0

If both of the instances use the same service account, and can login to eachother, and you can connect to one of the instances as sysadmin then you could use xp_cmdshell to create a login on the other instance.

E.G.

EXEC sp_configure 'show advanced options', 1;  
RECONFIGURE WITH OVERRIDE;
EXEC sp_configure 'xp_cmdshell', 1;  
RECONFIGURE WITH OVERRIDE;

exec master..xp_cmdshell 'SQLCMD -S SERVERNAME -Q  "CREATE LOGIN [Temp] WITH PASSWORD = ''P@SsWord12345'' exec sp_addsrvrolemember ''Temp'', ''sysadmin'' " ';

It isn't a very clean solution, but I used it once to grant myself access to other instances on the same machine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.