无法使用 Management Studio 连接到本地 SQL Server
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4810906/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cannot connect to local SQL Server with Management Studio
提问by Steve
I'm having an issue with SQL Server, I have 2005 installed on my desktop as well as having SQL Server Management Studio installed..
我的 SQL Server 有问题,我的桌面上安装了 2005 并且安装了 SQL Server Management Studio。
I've checked and can see "SQL Server (SQLEXPRESS)" started in services.
我已经检查并可以看到服务中启动的“SQL Server (SQLEXPRESS)”。
I've tried to connect to "Local" and "SQLEXPRESS" but both fail to connect.
我试图连接到“本地”和“SQLEXPRESS”,但都无法连接。
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) (.Net SqlClient Data Provider)
与 SQL Server 建立连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接。(提供程序:命名管道提供程序,错误:40 - 无法打开与 SQL Server 的连接)(.Net SqlClient 数据提供程序)
Anything else I need to do to connect to it??
我还需要做些什么才能连接到它?
UPDATE
更新
I seem to be getting a little further along now. Ive managed to connect to my server with SQL Server Management (FYI .\SQLEXPRESS did the trick) but now im having a issue with my connection string in my web.config
我现在似乎走得更远了。我已经设法使用 SQL Server Management 连接到我的服务器(仅供参考。\SQLEXPRESS 做到了),但现在我的 web.config 中的连接字符串出现问题
Ive im going to connect to this local sql server using windows authentication how do i need to structure it??
我要使用 Windows 身份验证连接到这个本地 sql 服务器,我需要如何构建它?
Something like this?
像这样的东西?
<add name="BensBoxing" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=BritBoxing_Alpha;Integrated Security=False;User Instance=True" providerName="System.Data.SqlClient"/>
This produces a error about
这会产生一个关于
Login failed for user ''.
用户 '' 登录失败。
采纳答案by Sam
Check the sql log in the LOG directory of your instance - see if anything is going on there. You'll need to stop the service to open the log - or restart and you can read the old one - named with .1 on the end.
检查实例的 LOG 目录中的 sql 日志 - 查看那里是否发生了任何事情。您需要停止服务以打开日志 - 或者重新启动,您可以阅读旧的 - 最后以 .1 命名。
With the error you're getting, you need to enable TCP/IP or Named pipes for named connections. Shared memory connection should work, but you seem to not be using that. Are you trying to connect through SSMS?
出现错误后,您需要为命名连接启用 TCP/IP 或命名管道。共享内存连接应该可以工作,但您似乎没有使用它。您是否尝试通过 SSMS 进行连接?
In my log I see entries like this...
在我的日志中,我看到这样的条目......
Server local connection provider is ready to accept connection on [\.\pipe\mssql$sqlexpress\sql\query ]
As the comments said, .\SQLEXPRESS should work. Also worstationName\SQLEXPRESS will work.
正如评论所说, .\SQLEXPRESS 应该可以工作。也wastationName\SQLEXPRESS 将工作。
回答by David
Same as matt said. The "SQL Server(SQLEXPRESS)" was stopped. Enabled it by opening Control Panel > Administrative Tools > Services, right-clicking on the "SQL Server(SQLEXPRESS)" service and selecting "Start" from the available options. Could connect fine after that.
和马特说的一样。“SQL Server(SQLEXPRESS)”已停止。通过打开控制面板 > 管理工具 > 服务,右键单击“SQL Server(SQLEXPRESS)”服务并从可用选项中选择“启动”来启用它。之后可以正常连接。
回答by matt
I was having this problem on a Windows 7 (64 bit) after a power outage. The SQLEXPRESS service was not started even though is status was set to 'Automatic' and the mahine had been rebooted several times. Had to start the service manually.
停电后,我在 Windows 7(64 位)上遇到了这个问题。即使状态设置为“自动”并且机器已重新启动数次,SQLEXPRESS 服务也未启动。不得不手动启动服务。
回答by Matias Osmerini
Try to see, if the service "SQL Server (MSSQLSERVER)" it's started, this solved my problem.
尝试查看,如果服务“SQL Server (MSSQLSERVER)”已启动,这解决了我的问题。
回答by Bapuji Behera
Open Sql server 2014 Configuration Manager.
打开 Sql server 2014 配置管理器。
Click Sql server services and start the sql server service if it is stopped
点击sql server服务,如果停止了就启动sql server服务
Then click Check SQL server Network Configuration for TCP/IP Enabled
然后单击 Check SQL server Network Configuration for TCP/IP Enabled
then restart the sql server management studio (SSMS) and connect your local database engine
然后重新启动sql server management studio(SSMS)并连接本地数据库引擎