I installed SQL Server 2005 sometime ago and forgot the administrator password I set during setup. How can I connect to SQL server now?
EDIT: I thin
For these steps to work, you need to be an admin on box where SQL Server is installed.
Add this -mSQLCMD command as one of the start up parameters, by right clicking the service and going into startup parameters section as shown in screenshot below and start SQL Server
Now connect to SQLSERVER from SQLCMD (open command prompt as admin) like below:
sqlcmd -s servername\instancename
And run below command:
USE [master]
GO
CREATE LOGIN [BUILTIN\Administrators] FROM WINDOWS WITH DEFAULT_DATABASE=[master]
GO
EXEC master..sp_addsrvrolemember @loginame = N'BUILTIN\Administrators', @rolename = N'sysadmin'
GO
Above command adds all local users as sysadmins. You may change this and add a user like or you can make another user sysadmin and remove BUILTIN\Administrators
Once this is done, you need to now stop SQL Server and remove -mSQLCMD parameter and restart SQL Server
References:
Help : I lost sa password and no one has System Administrator (SysAdmin) permission. What should I do?