我的系統重裝以前的d:\盤裝有sqlserver,後重裝裡系統後,原來裝在d:\下的sql服務卻啟動不起來了,沒有找到sqlserver的安裝光盤,於是我就嘗試能不能手動恢復sql服務。
我做了以下嘗試:
(1)。直接運行D:\Program Files\Microsoft SQL Server\MSSQL\Binn下的sqlservr.exe,發現他有一個參數:/c
作為一個服務運行,運行後的確可以通過企業管理器找到sqlserver,但是不方便,因為要啟動sqlserver就必須多運行一個DOS界面的窗口,我想把它作為一個後台服務運行。
(2)。通過注冊表添加sqlserver後台服務:
找到HKEY_LOCAL_MacHINE\SYSTEM\CurrentControlSet\Services\,下面就是系統中的所有的服務了,添加一個項:MSSQLSERVER,添加以下的健值:
"Type"=dWord:00000010
"Start"=dWord:00000002
"ErrorControl"=dWord:00000001
"ImagePath"=hex(2):64,00,3a,00,5c,00,50,00,52,00,4f,00,47,00,52,00,41,00,7e,00,\
31,00,5c,00,4d,00,53,00,53,00,51,00,4c,00,5c,00,62,00,69,00,6e,00,6e,00,5c,\
00,73,00,71,00,6c,00,73,00,65,00,72,00,76,00,72,00,2e,00,65,00,78,00,65,00,\
00,00
"DisplayName"="MSSQLSERVER"
"ObjectName"="LocalSystem"
其中的ImagesPath的健值也可以是字符串值:D:\Program Files\Microsoft SQL Server\MSSQL\Binn\sqlservr.exe
其中D:\Program Files\Microsoft SQL Server為你的sqlserver的目錄,
然後此項下添加子項:
Linkage
Performance
Security
Enum
重啟電腦在服務中就會添加MSSQLSERVER服務
然後,通過mmc新建一個管理單元,把此服務添加進去。
sqlserver 服務管理器也會檢測到並管理sqlserver
其中完整的reg如下,你可以復制下來存成 .reg 文件導入到注冊表中
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MacHINE\SYSTEM\CurrentControlSet\Services\MSSQLSERVER]
"Type"=dWord:00000010
"Start"=dWord:00000002
"ErrorControl"=dWord:00000001
"ImagePath"=hex(2):64,00,3a,00,5c,00,50,00,52,00,4f,00,47,00,52,00,41,00,7e,00,\
31,00,5c,00,4d,00,53,00,53,00,51,00,4c,00,5c,00,62,00,69,00,6e,00,6e,00,5c,\
00,73,00,71,00,6c,00,73,00,65,00,72,00,76,00,72,00,2e,00,65,00,78,00,65,00,\
00,00
"DisplayName"="MSSQLSERVER"
"ObjectName"="LocalSystem"
[HKEY_LOCAL_MacHINE\SYSTEM\CurrentControlSet\Services\MSSQLSERVER\Linkage]
"Export"=hex(7):4d,00,53,00,53,00,51,00,4c,00,53,00,45,00,52,00,56,00,45,00,52,\
00,00,00,00,00
[HKEY_LOCAL_MacHINE\SYSTEM\CurrentControlSet\Services\MSSQLSERVER\Performance]
"Library
"="d:\\PROGRA~1\\MSSQL\\BINN\\SQLCTR80.DLL"
"Collect"="CollectSQLPerformanceData"
"Open"="OpenSQLPerformanceData"
"Close"="CloseSQLPerformanceData"
"PerfIniFile"="sqlctr.ini"
"Last Counter"=dWord:000010c2
"Last Help"=dWord:000010c3
"First Counter"=dWord:00000fae
"First Help"=dWord:00000faf
"WbemAdapFileSignature"=hex:d6,a0,b9,c1,d1,85,78,63,4f,31,8b,f2,18,51,1a,5d
"WbemAdapFileTime"=hex:24,a2,b9,6d,3b,7d,c6,01
"WbemAdapFileSize"=dWord:0000803b
"WbemAdapStatus"=dWord:00000000
[HKEY_LOCAL_MacHINE\SYSTEM\CurrentControlSet\Services\MSSQLSERVER\Security]
"Security"=hex:01,00,14,80,b8,00,00,00,c4,00,00,00,14,00,00,00,30,00,00,00,02,\
00,1c,00,01,00,00,00,02,80,14,00,ff,01,0f,00,01,01,00,00,00,00,00,01,00,00,\
00,00,02,00,88,00,06,00,00,00,00,00,14,00,fd,01,02,00,01,01,00,00,00,00,00,\
05,12,00,00,00,00,00,18,00,ff,01,0f,00,01,02,00,00,00,00,00,05,20,00,00,00,\
20,02,00,00,00,00,14,00,8d,01,02,00,01,01,00,00,00,00,00,05,04,00,00,00,00,\
00,14,00,8d,01,02,00,01,01,00,00,00,00,00,05,06,00,00,00,00,00,14,00,00,01,\
00,00,01,01,00,00,00,00,00,05,0b,00,00,00,00,00,18,00,fd,01,02,00,01,02,00,\
00,00,00,00,05,20,00,00,00,23,02,00,00,01,01,00,00,00,00,00,05,12,00,00,00,\
01,01,00,00,00,00,00,05,12,00,00,00
[HKEY_LOCAL_MacHINE\SYSTEM\CurrentControlSet\Services\MSSQLSERVER\Enum]
"0"="Root\\LEGACY_MSSQLSERVER\\0000"
"Count"=dWord:00000001
"NextInstance"=dWord:00000001
導入之前一定要根據自己的機器的SQLserver安裝情況來適當修改才能行。差不多10分鐘就搞定了