无法连接到SQL Server 2005本地主机 [英] Cant connect to SQL Server 2005 localhost

查看:147
本文介绍了无法连接到SQL Server 2005本地主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图在本地主机上连接到SQL Server 2005,但无法连接...

I've been trying to connect to SQL Server 2005 on my localhost and I can not connect...

服务器名称:(本地)\ SQLEXPRESS
身份验证:Windows 身份验证

Server name: (local)\SQLEXPRESS
Authentication: Windows Authentication

我尝试过的其他服务器名称是

other Server name I have tried are

LOCALHOST \ SQLEXPRESS
(本地)\我的本地主机名

LOCALHOST\SQLEXPRESS
(local)\my local hostname

我收到此错误消息:

无法连接到127.0.0.1 \ SQLEXPRESS.
与网络相关或 建立与以下对象的连接时发生特定于实例的错误 SQL Server.服务器未找到或无法访问.核实 实例名称正确并且已将SQL Server配置为 允许远程连接.

Cannot connect to 127.0.0.1\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.

在服务中打开了SQL Server浏览器

SQL Server Browser is turned on in Services

有什么想法吗?

推荐答案

(1)

您需要验证(不仅仅是猜测)SQL Server服务正在运行.您可以通过以下方法执行此操作:转到开始">控制面板">管理工具">服务",然后检查服务SQL Server (SQLEXPRESS)是否正在运行.如果没有,请启动它.

You need to verify (not just guess) that the SQL Server service is running. You can do this by going to Start > Control Panel > Administrative Tools > Services, and checking that the service SQL Server (SQLEXPRESS) is running. If not, start it.

(2)

在服务小程序中时,还请确保服务SQL Browser已启动.如果没有,请启动它.

While you're in the services applet, also make sure that the service SQL Browser is started. If not, start it.

(3)

您需要确保允许SQL Server使用TCP/IP或命名管道.您可以通过打开SQL Server配置管理器(在开始">程序">"Microsoft SQL Server 2005">配置工具"下)打开这些文件,并确保已启用"TCP/IP"和命名管道".在这里我的实例名称不同,但是您可以看到这两个协议都被禁用了(您需要在Protocols for SQLEXPRESS下进行检查):

You need to make sure that SQL Server is allowed to use TCP/IP or named pipes. You can turn these on by opening the SQL Server Configuration Manager (found under Start > Programs > Microsoft SQL Server 2005 > Configuration Tools), and make sure that TCP/IP and Named Pipes are enabled. Here my instance name is different but you can see that both of these protocols are disabled (you'll want to check under Protocols for SQLEXPRESS):

(如果更改这些设置,则需要重新启动SQL Server服务.)

(You'll need to restart the SQL Server service if you change these settings.)

(4)

尽管在当前版本的SQL Server中不再使用它,您还需要检查外围应用配置器"工具.也可以在开始">程序">"Microsoft SQL Server 2005">配置工具"下找到此文件.单击服务和连接的外围区域配置",然后突出显示SQLEXPRESS(同样,我的本地实例名称为SQL2005,但假装它与您的实例相同),然后在数据库引擎">远程连接"下,启用本地和远程连接选项同时使用TCP/IP和命名管道".在下面的屏幕截图中,我仅启用了TCP/IP.如果更改了这些设置,请单击应用",然后再次需要重新启动SQL Server才能使更改生效.

While it is no longer used in current versions of SQL Server, you'll also want to check the Surface Area Configuration tool. This is also found under Start > Programs > Microsoft SQL Server 2005 > Configuration Tools. Click on "Surface Area Configuration for Services and Connections", then highlight SQLEXPRESS (again my local instance name is SQL2005 but pretend it's the same as yours), and under Database Engine > Remote Connections, enable "Local and remote connections" for the option "Using both TCP/IP and named pipes." In the screen shot below I only have TCP/IP enabled. If you change these settings, hit Apply, and again you'll need to restart SQL Server for the changes to take effect.

(这不会帮助您解决当前的问题,但是,如果您想从其他计算机连接到SQL Server,则可能需要启用它,这也可能会帮助将来尝试远程连接到SQL Server 2005的读者.)

(This won't help your current problem but you may need to enable this if you want to connect to SQL Server from other machines, and it may also help future readers who are trying to connect to SQL Server 2005 remotely.)

(5)

如果您以某种方式阻止自己,它也可能有助于暂时关闭Windows防火墙. (控制面板> Windows防火墙)

It may also help to shut off Windows Firewall temporarily, in case you are blocking yourself somehow. (Control Panel > Windows Firewall)

(6)

查看SQL Server的错误日志.您可以通过以下路径访问该文件:

Review SQL Server's error log. You can get to this file at a path something like:

C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\

(我没有Express实例,因此您的计算机上的路径可能略有不同.)

(I don't have an Express instance handy so the path might be slightly different on your machine.)

现在,在该文件夹中将有一个名为ERRORLOG的文件...这是上一次SQL Server启动时生成的最新日志文件.您可以右键单击此文件,然后选择打开方式...",然后选择记事本.您应该看到一些这样的行:

Now, in that folder there will be a file called ERRORLOG... this is the most recent log file that was generated the last time SQL Server started. You can right-click this file and choose Open With... select notepad. You should see some lines like this:

2012-05 ...身份验证模式为混合.
...
2012-05 ...
服务器名称为"something \ SQLEXPRESS".这是一个参考 仅消息.无需用户操作.
...
2012-05 ...服务器 本地连接提供商已准备好接受[ \.\ pipe \ SQLLocal \ SQLEXPRESS].
2012-05 ...服务器本地 连接提供者已准备好接受[ \.\ pipe \ MSSQL $ SQLEXPRESS \ sql \ query].
2012-05 ...服务器为 正在[[:1 49164]上监听.
2012-05 ...服务器正在监听 在[127.0.0.1 49164]上.
...
2012-05 ... SQL Server现已发布 准备客户端连接.这是一条情报信息;不 需要用户采取行动.

2012-05... Authentication mode is MIXED.
...
2012-05...
Server name is 'something\SQLEXPRESS'. This is an informational message only. No user action is required.
...
2012-05... Server local connection provider is ready to accept connection on [ \.\pipe\SQLLocal\SQLEXPRESS ].
2012-05... Server local connection provider is ready to accept connection on [ \.\pipe\MSSQL$SQLEXPRESS\sql\query ].
2012-05... Server is listening on [ ::1 49164].
2012-05... Server is listening on [ 127.0.0.1 49164].
...
2012-05... SQL Server is now ready for client connections. This is an informational message; no user action is required.

请告诉我们您看不到中的哪几行,以及第二行显示我写"something \ SQLEXPRESS"的地方.

Please tell us which of these lines you don't see, and what the second line says where I wrote "something\SQLEXPRESS".

这篇关于无法连接到SQL Server 2005本地主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆