1,、首先停止所有與SQLServer相關(guān)的服務(wù)
net stop "SQL Server Integration Services"
net stop "SQL Server FullText Search (MSSQLSERVER)"
net stop "SQL Server Agent (MSSQLSERVER)"
net stop "SQL Server Analysis Services (MSSQLSERVER)"
net stop "SQL Server Reporting Services (MSSQLSERVER)"
net stop "SQL Server Browser"
net stop "SQL Server (MSSQLSERVER)"
2、在命令行提示符下執(zhí)行
--SQL2005
cd C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn
sqlservr.exe -m
如果是命名實例執(zhí)行sqlservr.exe -m -s<Instance Name>
3、啟動另一個命令行窗口,,執(zhí)行 sqlcmd -E
4、在此窗口下執(zhí)行下面的命令
create login [builtin\administrators] from windows
go
exec sp_addsrvrolemember [builtin\administrators], [sysadmin]
go
ALTER LOGIN sa WITH PASSWORD='***'
go
shutdown
go
5,、關(guān)閉2個命令行窗口,,啟動sqlserver,一切Ok
net start "SQL Server Integration Services"
net start "SQL Server FullText Search (MSSQLSERVER)"
net start "SQL Server Agent (MSSQLSERVER)"
net start "SQL Server Analysis Services (MSSQLSERVER)"
net start "SQL Server Reporting Services (MSSQLSERVER)"
net start "SQL Server Browser"
net start "SQL Server (MSSQLSERVER)"