How to find SQL Server running port?

后端 未结 13 631
再見小時候
再見小時候 2020-11-28 20:10

Yes I read this How to find the port for MS SQL Server 2008?

no luck.

telnet 1433

returns connection failed, so I must s

相关标签:
13条回答
  • 2020-11-28 20:28

    SQL Server 2000 Programs | MS SQL Server | Client Network Utility | Select TCP_IP then Properties

    SQL Server 2005 Programs | SQL Server | SQL Server Configuration Manager | Select Protocols for MSSQLSERVER or select Client Protocols and right click on TCP/IP

    0 讨论(0)
  • 2020-11-28 20:29

    In our enterprise I don't have access to MSSQL Server, so I can'r access the system tables.

    What works for me is:

    1. capture the network traffic Wireshark (run as Administrator, select Network Interface),while opening connection to server.
    2. Find the ip address with ping
    3. filter with ip.dst == x.x.x.x

    The port is shown in the column info in the format src.port -> dst.port

    0 讨论(0)
  • 2020-11-28 20:30

    very simple. make a note of the sqlsrvr.exe PID from taskmanager then run this command:

    netstat -ano | findstr *PID*
    

    it will show TCP and UDP connections of your SQL server (including ports) standard is 1433 for TCP and 1434 for UDP

    example : enter image description here

    0 讨论(0)
  • 2020-11-28 20:30

    Perhaps not the best options but just another way is to read the Windows Registry in the host machine, on elevated PowerShell prompt you can do something like this:

    #Get SQL instance's Port number using Windows Registry:
    $instName = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server').InstalledInstances[0]
    $tcpPort = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$instName\MSSQLServer\SuperSocketNetLib\Tcp").TcpPort
    Write-Host The SQL Instance:  `"$instName`"  is listening on `"$tcpPort`"  "TcpPort."
    

    Ensure to run this PowerShell script in the Host Server (that hosts your SQL instance / SQL Server installation), which means you have to first RDP into the SQL Server/Box/VM, then run this code.

    HTH

    0 讨论(0)
  • 2020-11-28 20:32

    try once:-

    USE master
    DECLARE       @portNumber   NVARCHAR(10)
    EXEC   xp_instance_regread
    @rootkey    = 'HKEY_LOCAL_MACHINE',
    @key        =
    'Software\Microsoft\Microsoft SQL Server\MSSQLServer\SuperSocketNetLib\Tcp\IpAll',
    @value_name = 'TcpDynamicPorts',
    @value      = @portNumber OUTPUT
    SELECT [Port Number] = @portNumber
    GO
    
    0 讨论(0)
  • 2020-11-28 20:33
    select * from sys.dm_tcp_listener_states 
    

    More there: https://docs.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/sys-dm-tcp-listener-states-transact-sql?view=sql-server-2017

    0 讨论(0)
提交回复
热议问题