How to find the port for MS SQL Server 2008?

后端 未结 13 1750
广开言路
广开言路 2020-11-29 02:24

I am running MS SQL Server 2008 on my local machine. I know that the default port is 1433 but some how it is not listening at this port. The SQL is an Express edition.

相关标签:
13条回答
  • 2020-11-29 02:58

    This may also be done via a port scan, which is the only possible method if you don't have admin access to a remote server.

    Using Nmap (http://nmap.org/zenmap/) to do an "Intense TCP scan" will give you results like this for all instances on the server:

    [10.0.0.1\DATABASE]    
    Instance name: DATABASE
    Version: Microsoft SQL Server 2008 R2 RTM    
    Product: Microsoft SQL Server 2008 R2    
    Service pack level: RTM    
    TCP port: 49843    
    Named pipe: \\10.0.0.1\pipe\MSSQL$DATABASE\sql\query
    

    Important note: To test with query analyzer or MS SQL Server Management Studio you must form your server name and port differently than you would normally connect to a port, over HTTP for instance, using a comma instead of a colon.

    • Management Studio Server Name: 10.0.0.1,49843
    • Connection String: Data Source=10.0.0.1,49843

    however

    • JDBC Connection String: jdbc:microsoft:sqlserver://10.0.0.1:49843;DatabaseName=DATABASE
    0 讨论(0)
  • 2020-11-29 03:02

    Try this (requires access to sys.dm_exec_connections):

    SELECT DISTINCT 
        local_tcp_port 
    FROM sys.dm_exec_connections 
    WHERE local_tcp_port IS NOT NULL
    
    0 讨论(0)
  • 2020-11-29 03:02
    USE master
    GO
    xp_readerrorlog 0, 1, N'Server is listening on', 'any', NULL, NULL, N'asc' 
    GO
    

    [Identify Port used by Named Instance of SQL Server Database Engine by Reading SQL Server Error Logs]

    0 讨论(0)
  • 2020-11-29 03:05

    Here are 5 methodes i found:

    • Method 1: SQL Server Configuration Manager
    • Method 2: Windows Event Viewer
    • Method 3: SQL Server Error Logs
    • Method 4: sys.dm_exec_connections DMV
    • Method 5: Reading registry using xp_instance_regread

    Method 4: sys.dm_exec_connections DMV
    I think this is almost the easiest way...
    DMVs return server state that can be used to monitor SQL Server Instance. We can use sys.dm_exec_connections DMV to identify the port number SQL Server Instance is listening on using below T-SQL code:

    SELECT local_tcp_port
    FROM   sys.dm_exec_connections
    WHERE  session_id = @@SPID
    GO
    
    Result Set:
    local_tcp_port
    61499
    
    (1 row(s) affected)
    

    Method 1: SQL Server Configuration Manager

    Step 1. Click Start > All Programs > Microsoft SQL Server 2012 > Configuration Tools > SQL Server Configuration Manager

    Step 2. Go to SQL Server Configuration Manager > SQL Server Network Configuration > Protocols for

    Step 3. Right Click on TCP/IP and select Properties

    enter image description here

    Step 4. In TCP/IP Properties dialog box, go to IP Addresses tab and scroll down to IPAll group.

    enter image description here

    If SQL Server if configured to run on a static port it will be available in TCP Port textbox, and if it is configured on dynamic port then current port will be available in TCP Dynamic Ports textbox. Here my instance is listening on port number 61499.

    The other methods you can find here: http://sqlandme.com/2013/05/01/sql-server-finding-tcp-port-number-sql-instance-is-listening-on/

    0 讨论(0)
  • 2020-11-29 03:06

    In the ERROLOG log for a line like below. If you don't see it the SQL Server isn't enabled for remote access, or it is just not via TCP. You can change this via the SQL Server Configuration Manager.

    Server is listening on [ 192.128.3.2 <ipv4> 1433].
    
    0 讨论(0)
  • 2020-11-29 03:10

    I solved the problem by enabling the TCP/IP using the SQL Server Configuration Manager under Protocols for SQLEXPRESS2008, i restarted the service and now the "Server is listening on" shows up in the ERRORLOG file

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