部署后SQL无法连接 [英] SQL won't connect after deploying
问题描述
我最近在IIS(LocalDB)上部署了我的网站.但是,每当我尝试运行该网站时,SQL都将无法连接.我已经浏览了数百篇文章/文章,但无法解决.
I recently deployed my website on IIS (LocalDB). But whenever I try to run the website, the SQL fails to connect. I've been through hundreds of posts/articles now but I am unable to resolve it.
错误
与网络相关或特定于实例的错误发生在 建立与SQL Server的连接.找不到服务器或 无法访问.验证实例名称正确,并且 SQL Server配置为允许远程连接. (提供者:SQL 网络接口,错误:50-发生本地数据库运行时错误. 无法创建自动实例.请参阅Windows应用程序事件 记录错误详细信息. )
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: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details. )
Windows应用程序事件日志
Windows API调用SHGetKnownFolderPath返回了错误代码:5. Windows 系统错误消息是:访问被拒绝.报告在第422行.
Windows API call SHGetKnownFolderPath returned error code: 5. Windows system error message is: Access is denied. Reported at line: 422.
第二个日志-
无法获取本地应用程序数据路径.最有可能是用户个人资料 未加载.如果在IIS下执行LocalDB,请确保 当前用户已启用个人资料加载.
Cannot get a local application data path. Most probably a user profile is not loaded. If LocalDB is executed under IIS, make sure that profile loading is enabled for the current user.
我的连接字符串(均尝试)-
<appSettings>
<add key="ConnectionString" value="Data Source=(LocalDB)\MSSQLLocalDB;Initial Catalog=test;Integrated Security=True" />
<!--<add key="ConnectionString" value="data source=(LocalDB)\MSSQLLocalDB;UID=SOME_USERNAME;PWD=SOME_PASSWORD;initial catalog=test;connection timeout=30"/>-->
</appSettings>
我尝试编辑 applicationHost.config .
加载用户个人资料已经为True对我来说
I tried editing applicationHost.config.
Load User Profile was already True for me
我的ApplicationHost.config文件
My ApplicationHost.config file
<applicationPools>
<add name="Classic .NET AppPool" managedRuntimeVersion="v2.0" managedPipelineMode="Classic" />
<add name=".NET v2.0 Classic" managedRuntimeVersion="v2.0" managedPipelineMode="Classic" />
<add name=".NET v2.0" managedRuntimeVersion="v2.0" />
<add name=".NET v4.5 Classic" managedRuntimeVersion="v4.0" managedPipelineMode="Classic" />
<add name=".NET v4.5" managedRuntimeVersion="v4.0" />
<add name="ASP.NET v4.0" managedRuntimeVersion="v4.0">
<add name="DefaultAppPool" autoStart="true" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated">
<processModel identityType="ApplicationPoolIdentity" loadUserProfile="true" setProfileEnvironment="true" />
</add>
</applicationPools>
我的IIS管理器-
DefaultApplicationPool -
我的Web应用程序配置-
应用程序池权限
编辑-
使用添加了IIS Apppool
Added IIS Apppool using
icacls c:\inetpub\wwwroot /grant "IIS APPPOOL\DefaultAppPool":(OI)(CI)(RX)
仍然无法连接.
感谢您的帮助.
我在使用Visual Studio 2015和SQL Server 2016的Windows 10上.
I am on Windows 10 using Visual Studio 2015 with SQL Server 2016.
推荐答案
出现了同样的问题.不过,我并未尝试您所做的所有事情.我做了以下事情:
Had this same problem. I didn't try all the things you did, though. I did the following:
- IIS管理器
- 应用程序池
- 找到您的应用所属的池(对我来说是
.NET v4.5
) - 右键单击->高级设置
- 向下滚动到
Identity
- 从任何内容(对我来说,是
ApplicationPoolIdentity
,与您一样)更改为LocalSystem
.
- IIS Manager
- Application Pools
- Find the pool your app belongs to (for me it was
.NET v4.5
) - Right click -> Advanced Settings
- Scroll down to
Identity
- Change from whatever (for me it was
ApplicationPoolIdentity
, same as you have) intoLocalSystem
.
这篇关于部署后SQL无法连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!