2014年5月17日星期六

SQL Server 无法连接(Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

.net web程序运行时出错:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

1、查看原因是数据库没有启动,然后尝试启动数据库,无法启动并报错。

2、查看windows日志->应用程序日志,找到SQL Server的错误日志,可以看到错误日志EventID为17058。然后解决EventID:17058的问题。


出现错误:SQL Server默认实例(MSSQLSERVER)无法启动,错误代码:17058


日志错误信息:
initerrlog: Could not open error log file 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG'. Operating system error = 5(Access is denied.).

The event ID in the application log is 17058. Also the following error message appears in the system log 

The SQL Server (MSSQLSERVER) service terminated with service-specific error 17058 (0x42A2).

分析原因:安装AD后,系统改为使用域用户登陆,原先安装SQL时设置的“本地用户”信息已经修改,当前(域)用户没有权限访问MSSQLSERVER实例文件夹或整个SQL文件夹

解决方法:
1、打开“服务”,找到SQL Server(MSSQLSERVER)服务(或设置实例所对应的服务),查看属性,在“登陆”标签中选择“本地系统账户”


2、为保险起见,进行这步操作:打开SQL Server Configuration Manager(SQL Server配置管理器),在SQL Server Service(SQL Server服务)中找到对应实例(名称和“服务”中的名称相同)。在“登陆”标签中选择“内置账户”,并选择“Local System”(全其他如NETWORK SERVICE也可以,但要保证有权限)

3、启动SQL Server(MSSQLSERVER)服务。

4、如果还是出错(如126错误),那么进入SQL Server的安装目录,给整个安装目录分配NETWORK SERVICE及当前登录用户的权限,特别是实例所在目录,以及数据库文件相关目录,分配写权限。完成后再次启动服务。

结果:成功启动SQL Server(MSSQLSERVER)服务。

没有评论:

发表评论