如何识别SQL Server的端口号

Ank*_*ain 35 sql sql-server

我在我的系统中安装SQL服务器,我必须检查SQL在我的系统中工作的端口号

Pun*_*015 57

  1. 打开SQL Server Management Studio
  2. 连接到您需要端口号的数据库引擎
  3. 对数据库运行以下查询

    select distinct local_net_address, local_tcp_port from sys.dm_exec_connections where local_net_address is not null

以上查询显示本地IP以及侦听端口号

  • 没有返回任何行. (7认同)
  • @trilawney如果您在本地连接到数据库,则不会返回任何行。您将必须远程连接到数据库。在本地连接时,它将使用共享内存进行连接;在远程连接时,它将通过TCP连接。 (2认同)

Ank*_*ain 27

 Open Run in your system
 Type %windir%\System32\cliconfg.exe 
 Click on ok button then check an TCP ip pop-up is open 
 Highlight TCP/IP under the Enabled protocols window.
 Click the Properties button.
 Enter in the new port number, then click OK.
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述


Sun*_*wal 16

您也可以使用此查询

USE MASTER GO xp_readerrorlog 0, 1, N'Server is listening on' GO

来源:sqlauthority博客


Yur*_*ter 12

在视觉上,您可以打开"SQL Server配置管理器"并检查"网络配置"的属性:

SQL Server配置


小智 6

这个查询对我有用:

SELECT DISTINCT 
    local_tcp_port 
FROM sys.dm_exec_connections 
WHERE local_tcp_port IS NOT NULL 
Run Code Online (Sandbox Code Playgroud)


Bar*_*z X 6

PowerShell 解决方案显示主机上的所有实例及其传入流量地址。如果您只知道 DNS,第二部分可能会有所帮助:

ForEach ($SQL_Proc in Get-Process | Select-Object -Property ProcessName, Id | Where-Object {$_.ProcessName -like "*SQL*"})
{
    Get-NetTCPConnection | `
     Where-Object {$_.OwningProcess -eq $SQL_Proc.id} | `
      Select-Object -Property `
                                @{Label ="Process_Name";e={$SQL_Proc.ProcessName}}, `
                                @{Label ="Local_Address";e={$_.LocalAddress + ":" + $_.LocalPort }},  `
                                @{Label ="Remote_Address";e={$_.RemoteAddress + ":" + $_.RemotePort}}, State | `
      Format-Table
} 
Run Code Online (Sandbox Code Playgroud)


Pac*_*aco 5

要检查在所有端口上侦听的所有应用程序,请使用以下命令:

netstat -ntpl
Run Code Online (Sandbox Code Playgroud)

  • 在 Windows Server 2008 和 Windows 7 上,我需要使用 `netstat -ap TCP` 来显示监听(和连接)的 TCP 端口 (5认同)