SQL Server 不允许进行远程连接 解决办法

网络引用:http://www.cnblogs.com/noviceliu/archive/2007/10/22/933134.html     
     刚刚安装的数据库系统,按照默认安装的话,很可能在进行远程连接时报错,通常是错误:"在连接到 SQL Server 2005 时,在默认的设置下 SQL Server 不允许进行远程连接可能会导致此失败。 (provider: 命名管道提供程序, error: 40 - 无法打开到 SQL Server 的连接) "MSDN,上面有一片机器翻译的文章,是在让人难以明白,现在总结如下:明白了SQL Server是个网络数据库就可迎刃而解了,简单的分为下面的集中情况。

1.        数据库引擎没有启动。

  有两种启动方式:

     (1)开始->程序->Microsoft SQL Server 2005->SQL Server 2005外围应用配置器,在打开的界面单击"服务的连接的外围应用配置器",在打开的界面中找到Database Engine,单击"服务",在右侧查看是否已启动,如果没有启动可单击"启动",并确保"启动类型"为自动,不要为手动,否则下次开机时又要手动启动;

     (2)可打开:开始->程序->Microsoft SQL Server 2005->配置工具->SQL Server Configuration Manager,选中SQL Server 2005服务中SQL Server(MSSQLSERVER) ,并单击工具栏中的"启动服务"按钮把服务状态改为启动;

      使用上面两种方式时,有时候在启动的时候可能会出现错误,不能启动,这时就要查看"SQL Server 2005配置管理器"中的SQL  Server 2005网络配置->MSSQLSERVER协议中的VIA是否已启用,如果已启用,则把它禁止.然后再执行上述一种方式操作就可以了.

2.        是否已经允许远程连接。

这个部分可以简单的分为4个方面,分别是在 SQL Server上启用远程连接、启用SQL Server 浏览服务、在Windows 防火墙中为SQL Server 2005 创建例外和在Windows 防火墙中为“SQLBrowser”创建例外。下面是几个具体的操作方式,摘自MSDN,个人觉得文章的黑体部分应当特别的一起我们的注意。


  在SQLServer 实例上启用远程连接
1.
指向开始->程序->Microsoft SQL Server 2005->配置工具->SQL Server 外围应用配置器
2.
“SQL Server 2005 外围应用配置器, 单击服务和连接的外围应用配置器
3.
然后单击展开数据库引擎, 选中远程连接在右边选中本地连接和远程连接
再选择要使用的协议,( 这个地方应当启用TCP/IP 和命名管道服务!)
单击应用,您会看到下消息:
直到重新启动数据库引擎服务后,对连接设置所做的更改才会生效。,单击确定按钮返回
4.
展开数据库引擎, 选中服务,在右边单击停止,等到 MSSQLSERVER 服务停止,
然后单击启动,重新启动MSSQLSERVER 服务。

启用 SQLServer 浏览器服务
1.
指向开始->程序->Microsoft SQL Server 2005->配置工具->SQL Server 外围应用配置器
2.
“SQL Server 2005 外围应用配置器, 单击服务和连接的外围应用配置器
3.
然后单击展开“SQL Server Browser”, 选中服务,在右边启动类型选择自动
再单击启动,单击确定按钮返回

Windows 防火墙中为“SQL Server 2005”创建例外
1.
Windows 防火墙设置界面中,选择例外选项卡,然后单击添加程序
2.
添加程序窗口中单击浏览
3.
然后找到“C:\ProgramFiles\Microsoft Files\Microsoft SQL Server\ MSSQL.1 \MSSQL\Binn\sqlservr.exe”
单击确定返回
注意 : 路径可能会根据 SQL Server 2005 安装不同而不同。 MSSQL.1 是占位符,对应数据库实例ID
4.
对每个需要打开远程访问的SQL Server 2005 实例,重复步骤 1 3

Windows 防火墙中为“SQLBrowser”创建例外
1.
Windows 防火墙设置界面中,选择例外选项卡,然后单击添加程序
2.
添加程序窗口中单击浏览
3.
然后找到“C:\ProgramFiles\Microsoft Files\Microsoft SQL Server\90\Shared\sqlbrowser.exe”
单击确定返回
注意 : 路径可能会根据 SQL Server 2005 安装不同而不同。

 

在使用.NET开发进行时,会遇到使用连接字符串连接SQL Server 2005数据库使用机器名称和localhost都能连接,但是使用IP地址却不能连接的问题,解决的办法是在SQL Server实例上启用本地和远程连接,并且在选择协议的时候使用TCP/IP和命名管道服务即可解决。



官方帮助:

Details
Product: SQL Server
ID: -1
Source: MSSQLServer
Version: 9.0
Component: SQLEngine
Message: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 28 - Server doesn't support requested protocol) (Microsoft SQL Server, Error: -1)
   
Explanation

The SQL Server client cannot connect to the server. This error could be caused by one of the following reasons:

The firewall on the server has refused the connection.

A specified SQL Server instance name is not valid.

The SQL Server Browser service (sqlbrowser) is not started.

   
User Action

To resolve this error, try one of the following actions:

Make sure that you have configured the firewall on the server instance of SQL Server to open the SQL Server Browser port.

Make sure that the SQL Server Browser service is started on the server.

Check the spelling of the SQL Server instance name that is specified in the connection string.

Use the SQL Server Surface Area Configuration tool to enable SQL Server to accept remote connections. For more information about the SQL Server Surface Area Configuration Tool, see Surface Area Configuration for Services and Connections.


解决办法:我开始是通过浏览查找局域网服务器的,最后改成服务器ip,问题解决!
posted on 2007-12-28 09:41  品茶  阅读(2104)  评论(2编辑  收藏  举报