禁止服务器的协议,启用或禁用服务器网络协议
啟用或禁用服務(wù)器網(wǎng)絡(luò)協(xié)議
06/30/2015
本文內(nèi)容
所有網(wǎng)絡(luò)協(xié)議都是由 SQL Server 安裝程序安裝的,可以啟用也可以禁用這些網(wǎng)絡(luò)協(xié)議。 本主題介紹如何通過使用 SQL Server 配置管理器或 PowerShell,在 SQL Server 2012 中啟用或禁用服務(wù)器網(wǎng)絡(luò)協(xié)議。 必須停止并重新啟動數(shù)據(jù)庫引擎,更改才能生效。
安全說明
在安裝 SQL Server Express 過程中,將為 BUILTIN\Users 組添加一個登錄名。 這使得計算機的所有通過身份驗證的用戶能夠作為 public 角色的成員訪問 SQL Server Express 實例。 可以安全地刪除 BUILTIN\Users 登錄名,以便將數(shù)據(jù)庫引擎訪問限制為具有單獨登錄名的計算機用戶或具有登錄名的其他 Windows 組成員的計算機用戶。
本主題內(nèi)容
使用以下工具啟用或禁用服務(wù)器網(wǎng)絡(luò)協(xié)議:
SQL Server 配置管理器
PowerShell
使用 SQL Server 配置管理器
啟用服務(wù)器網(wǎng)絡(luò)協(xié)議
在 SQL Server 配置管理器的控制臺窗格中,展開**“SQL Server 網(wǎng)絡(luò)配置”**。
在控制臺窗格中,單擊**“ 的協(xié)議”**。
在細節(jié)窗格中,右鍵單擊要更改的協(xié)議,再單擊**“啟用”或“禁用”**。
在控制臺窗格中,單擊**“SQL Server 服務(wù)”**。
在詳細信息窗格中,右鍵單擊**“SQL Server ()”,再單擊“重新啟動”**以停止并重新啟動 SQL Server 服務(wù)。
[Top]
使用 SQL Server PowerShell
使用 PowerShell 啟用服務(wù)器網(wǎng)絡(luò)協(xié)議
使用管理員權(quán)限打開一個命令提示符。
可以從任務(wù)欄啟動 Windows PowerShell 2.0,也可以通過依次單擊“開始”、“所有程序”、“附件”、“Windows PowerShell”、“Windows PowerShell”來啟動。
通過輸入 Import-Module “sqlps” 導(dǎo)入 sqlps 模塊
執(zhí)行以下語句以啟用 TCP 和 Named Pipes 協(xié)議。 將 替換為運行 SQL Server 的計算機的名稱。 如果您在配置命名實例,請將 MSSQLSERVER 替換為該實例的名稱。
若要禁用協(xié)議,請將 IsEnabled 屬性設(shè)置為 $false。
$smo = 'Microsoft.SqlServer.Management.Smo.'
$wmi = new-object ($smo + 'Wmi.ManagedComputer').
# List the object properties, including the instance names.
$Wmi
# Enable the TCP protocol on the default instance.
$uri = "ManagedComputer[@Name='']/ ServerInstance[@Name='MSSQLSERVER']/ServerProtocol[@Name='Tcp']"
$Tcp = $wmi.GetSmoObject($uri)
$Tcp.IsEnabled = $true
$Tcp.Alter()
$Tcp
# Enable the named pipes protocol for the default instance.
$uri = "ManagedComputer[@Name='']/ ServerInstance[@Name='MSSQLSERVER']/ServerProtocol[@Name='Np']"
$Np = $wmi.GetSmoObject($uri)
$Np.IsEnabled = $true
$Np.Alter()
$Np
為本地計算機配置協(xié)議
當腳本在本地運行并配置本地計算機時,SQL Server PowerShell 可以通過動態(tài)確定本地計算機的名稱使腳本更為靈活。 若要檢索本地計算機的名稱,請將設(shè)置 $uri 變量的行替換為以下行。
$uri = "ManagedComputer[@Name='" + (get-item env:\computername).Value + "']/ServerInstance[@Name='MSSQLSERVER']/ServerProtocol[@Name='Tcp']"
使用 SQL Server PowerShell 重新啟動數(shù)據(jù)庫引擎
啟用或禁用了協(xié)議后,必須停止并重新啟動數(shù)據(jù)庫引擎才能使更改生效。 執(zhí)行以下語句,通過使用 SQL Server PowerShell 來停止和啟動默認實例。 若要停止和啟動命名實例,請將 'MSSQLSERVER' 替換為 'MSSQL$'。
# Get a reference to the ManagedComputer class.
CD SQLSERVER:\SQL\
$Wmi = (get-item .).ManagedComputer
# Get a reference to the default instance of the Database Engine.
$DfltInstance = $Wmi.Services['MSSQLSERVER']
# Display the state of the service.
$DfltInstance
# Stop the service.
$DfltInstance.Stop();
# Wait until the service has time to stop.
# Refresh the cache.
$DfltInstance.Refresh();
# Display the state of the service.
$DfltInstance
# Start the service again.
$DfltInstance.Start();
# Wait until the service has time to start.
# Refresh the cache and display the state of the service.
$DfltInstance.Refresh(); $DfltInstance
[Top]
總結(jié)
以上是生活随笔為你收集整理的禁止服务器的协议,启用或禁用服务器网络协议的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 计算机系统结构怎么提高代码效率,北邮 计
- 下一篇: 我的世界手机版服务器显示即将推出,我的世