Mssql怎么安装安全补钉?
Microsoft SQL Server(MSSql)是一种关系型数据库管理系统,是一款利用于生产和开发的强大工具,可以支持较大量的数据量和交互功能。由于MSSQL服务器的广泛利用,很多安全漏洞也会终究影响到MSSql服务器,因此,我们需要定期安装MSSql安全补钉。
首先,确保在安装MSSql服务器之前运行Windows更新,可使用下面的代码检查:
@echo off
wmic qfe get Caption,Description,HotFixID,InstalledOn
上述代码会列出更新,接下来选择想要安装的具体补钉,安装每次更新的安全补钉,可使用Win32 API函数来完成安装:
#include
#include
int InstallUpdate(wchar_t *strUpdate);
int main(int argc, char* argv[])
{
wchar_t strUpdate[] = L"ExactCabName.cab"; //CAB包名
int result = InstallUpdate(strUpdate);
if (result == 0)
{
printf("Update installed sucessfully.\n");
}
else
{
printf("Update failed with error code %d.\n", result);
}
system("pause");
return 0;
}
int InstallUpdate(wchar_t *strUpdate)
{
HANDLE hUpdateSession = NULL;
int result;
wchar_t Path[128], PatchCode[128];
wcscpy_s(Path, L"E:\\Update\\");
wcscat_s(Path, strUpdate);
wcscpy_s(PatchCode, L"KB123456"); //补钉编号
// 开始会话
if (::SUSStartSession(&hUpdateSession, NULL, NULL) != S_OK)
{
return ⑴;
}
// 安装补钉
if (::SUSInstallSingleUpdateW(hUpdateSession,
Path, PatchCode,
NULL, NULL, NULL, NULL) == S_OK)
{
result = 0;
}
else
{
result = ⑵;
}
// 结束会话
if (::SUSEndSession(hUpdateSession, 0) != S_OK)
{
result = ⑶;
}
return result;
}
上述代码将启动一个新会话,然后安装指定的补钉,最后结束会话。
另外,还可使用SQL脚本将更新补钉利用到数据库。在运行下面的SQL脚本之前,需要确保用户有安装补钉的权限:
EXEC sp_MshaustedFix 'LSOPatch\123456.EXE'
GO
该脚本使用sp_MshaustedFix存储进程来安装更新补钉。
总之,要安装Mssql安全补钉的方法比较丰富,用户可以通过win32 API函数或SQL脚本来安装更新补钉。但最重要的是要确保在安装Mssql服务器之前运行Windows更新,以确保Mssql服务器能够充分受益于目前可用的安全漏洞修复补钉。
文章来源:丸子建站
文章标题:Mssql怎么安装安全补钉?
https://www.wanzijz.com/view/13333.html