cf2000 发表于 2015-7-2 10:17:08

更改SQL SERVER默认端口

  今天遇到一个问题,sql server无法登陆,到Services里看,服务没有起来。但是在启动Service时遇到问题说无法启动。去Administrative Tools->Event Viewer中查看了一下,发现如下错误(该错误在SQL Server日志中也可以查看到,目录在C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Log):
  Server TCP provider failed to listen on [ 'any'1433]. Tcp port is already in use.
  TDSSNIClient initialization failed with error 0x2740, status code 0xa. Reason: Unable to initialize the TCP/IP listener. Only one usage of each socket address (protocol/network address/port) is normally permitted.
  知道可以用netstat -ano命令查看系统端口的使用情况。检查后没有发现1433端口在使用。
  所以直接改了SQL Server的TCP/IP端口。更改办法如下:

[*]In SQL Server Configuration Manager, expand SQL Server Network Configuration, and then click on the server instance you want to configure.
[*]In the right pane, double-click TCP/IP.
[*]In the TCP/IP Properties dialog box, click the IP Addresses tab.
[*]In the TCP Port box of the IPAll section, type an available port number. For this tutorial, we will use 1500.
[*]Click OK to close the dialog box, and click OK to the warning that the service must be restarted.
[*]In the left pane, click SQL Server Services.
[*]In the right pane, right-click the instance of SQL Server, and then click Restart. When the Database Engine restarts, it will listen on port 1500.
  更改后终于可以访问了。
  
  附:netstat命令详细解释

  netstat的全部参数及说明如下:
显示协议统计信息和当前 TCP/IP 网络连接。
  NETSTAT [-a] [-b] [-e] [-n] [-o] [-p proto] [-r] [-s] [-v]   -a            显示所有连接和监听端口。
-b            显示包含于创建每个连接或监听端口的
                可执行组件。在某些情况下已知可执行组件
                拥有多个独立组件,并且在这些情况下
                包含于创建连接或监听端口的组件序列
                被显示。这种情况下,可执行组件名
                在底部的 [] 中,顶部是其调用的组件,
                等等,直到 TCP/IP 部分。注意此选项
                可能需要很长时间,如果没有足够权限
                可能失败。
-e            显示以太网统计信息。此选项可以与 -s
                选项组合使用。
-n            以数字形式显示地址和端口号。
-o            显示与每个连接相关的所属进程 ID。
-p proto      显示 proto 指定的协议的连接;proto 可以是
                下列协议之一: TCP、UDP、TCPv6 或 UDPv6。
                如果与 -s 选项一起使用以显示按协议统计信息,proto 可以是下列协议
之一:
                IP、IPv6、ICMP、ICMPv6、TCP、TCPv6、UDP 或 UDPv6。
-r            显示路由表。
-s            显示按协议统计信息。默认地,显示 IP、
                IPv6、ICMP、ICMPv6、TCP、TCPv6、UDP 和 UDPv6 的统计信息;
                -p 选项用于指定默认情况的子集。
-v            与 -b 选项一起使用时将显示包含于
                为所有可执行组件创建连接或监听端口的
                组件。
interval      重新显示选定统计信息,每次显示之间
                暂停时间间隔(以秒计)。按 CTRL+C 停止重新
                显示统计信息。如果省略,netstat 显示当前
                配置信息(只显示一次)
页: [1]
查看完整版本: 更改SQL SERVER默认端口