不能连接到SQL Server 2005本地主机

时间:2023-01-15 21:00:26

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

我一直在尝试在本地主机上连接SQL Server 2005,但是我无法连接……

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

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

other Server name I have tried are

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

LOCALHOST\SQLEXPRESS
(local)\my local hostname

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

I get this error message:

我得到了这个错误信息:

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.

不能连接到127.0.0.1 \ SQLEXPRESS。在建立到SQL Server的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名是否正确,并将SQL Server配置为允许远程连接。

SQL Server Browser is turned on in Services

服务中打开SQL Server浏览器

any ideas?

什么好主意吗?

3 个解决方案

#1


19  

(1)

(1)

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.

您需要验证(而不是猜测)SQL Server服务正在运行。可以通过启动>控制面板>管理工具>服务并检查服务SQL Server (SQLEXPRESS)是否正在运行来实现这一点。如果不是,启动它。

(2)

(2)

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

在服务applet中,还要确保启动了服务SQL浏览器。如果不是,启动它。

(3)

(3)

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服务器使用TCP/IP或命名管道。您可以打开SQL Server配置管理器(在Start >程序下找到> Microsoft SQL Server 2005 >配置工具),并确保启用TCP/IP和命名管道。这里我的实例名不同,但是您可以看到这两个协议都被禁用了(您需要在SQLEXPRESS协议下检查):

不能连接到SQL Server 2005本地主机

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

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

(4)

(4)

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的当前版本中使用,但是您也需要检查一下Surface Area配置工具。这也可以在启动>程序> Microsoft SQL Server 2005 >配置工具下找到。单击“服务和连接的表面积配置”,然后突出显示SQLEXPRESS(同样我的本地实例名是SQL2005,但假设它与您的相同),并在数据库引擎>远程连接下,启用“本地和远程连接”选项“使用TCP/IP和命名管道”。在下面的屏幕截图中,我只启用了TCP/IP。如果您更改了这些设置,点击Apply,您将再次需要重新启动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.)

(这对您当前的问题没有帮助,但是如果您想从其他机器连接到SQL Server,那么您可能需要启用这个功能,而且它还可能帮助将来试图远程连接SQL Server 2005的读者。)

(5)

(5)

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

它还可能有助于暂时关闭Windows防火墙,以防你以某种方式阻止自己。(控制面板> Windows防火墙)

(6)

(6)

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

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

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

C:\Program Files\Microsoft SQL Server \ MSSQL.1 \该日志\ \

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

(我手头没有一个Express实例,所以您的机器上的路径可能略有不同。)

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:

现在,在那个文件夹里有一个文件叫做ERRORLOG…这是上次SQL Server启动时生成的最新日志文件。您可以右键单击这个文件,选择Open With…选择记事本。你应该看到这样的句子:

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.

2012 - 05年……身份验证模式是混合的。2012 - 05年……服务器名称是“东西\ SQLEXPRESS”。这只是一条信息。不需要用户操作。2012 - 05年……服务器本地连接提供程序已经准备好接受[\]上的连接。管道\ \ SQLLocal \ SQLEXPRESS]。2012 - 05年……服务器本地连接提供程序已经准备好接受[\]上的连接。管道\ \查询该SQLEXPRESS美元\ sql \]。2012 - 05年……服务器正在监听[:1 49164]。2012 - 05年……服务器正在监听[127.0.0.1 49164]。2012 - 05年……SQL Server现在已经为客户端连接做好了准备。这是一个信息信息;不需要用户操作。

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

请告诉我们你没有看到哪一行,第二行写的是什么?

#2


0  

If You have installed VS2008 then re-install sqlexpress2005 part once more or additionally you need to install that one then it will automatically fix its server name.

如果您已经安装了VS2008,那么重新安装sqlexpress2005的一部分,或者您需要安装它,然后它将自动修复它的服务器名称。

#3


0  

Make sure you have enabled the client protocols using the SQL Server Configuration Manager.

确保使用SQL Server Configuration Manager启用了客户端协议。

#1


19  

(1)

(1)

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.

您需要验证(而不是猜测)SQL Server服务正在运行。可以通过启动>控制面板>管理工具>服务并检查服务SQL Server (SQLEXPRESS)是否正在运行来实现这一点。如果不是,启动它。

(2)

(2)

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

在服务applet中,还要确保启动了服务SQL浏览器。如果不是,启动它。

(3)

(3)

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服务器使用TCP/IP或命名管道。您可以打开SQL Server配置管理器(在Start >程序下找到> Microsoft SQL Server 2005 >配置工具),并确保启用TCP/IP和命名管道。这里我的实例名不同,但是您可以看到这两个协议都被禁用了(您需要在SQLEXPRESS协议下检查):

不能连接到SQL Server 2005本地主机

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

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

(4)

(4)

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的当前版本中使用,但是您也需要检查一下Surface Area配置工具。这也可以在启动>程序> Microsoft SQL Server 2005 >配置工具下找到。单击“服务和连接的表面积配置”,然后突出显示SQLEXPRESS(同样我的本地实例名是SQL2005,但假设它与您的相同),并在数据库引擎>远程连接下,启用“本地和远程连接”选项“使用TCP/IP和命名管道”。在下面的屏幕截图中,我只启用了TCP/IP。如果您更改了这些设置,点击Apply,您将再次需要重新启动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.)

(这对您当前的问题没有帮助,但是如果您想从其他机器连接到SQL Server,那么您可能需要启用这个功能,而且它还可能帮助将来试图远程连接SQL Server 2005的读者。)

(5)

(5)

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

它还可能有助于暂时关闭Windows防火墙,以防你以某种方式阻止自己。(控制面板> Windows防火墙)

(6)

(6)

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

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

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

C:\Program Files\Microsoft SQL Server \ MSSQL.1 \该日志\ \

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

(我手头没有一个Express实例,所以您的机器上的路径可能略有不同。)

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:

现在,在那个文件夹里有一个文件叫做ERRORLOG…这是上次SQL Server启动时生成的最新日志文件。您可以右键单击这个文件,选择Open With…选择记事本。你应该看到这样的句子:

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.

2012 - 05年……身份验证模式是混合的。2012 - 05年……服务器名称是“东西\ SQLEXPRESS”。这只是一条信息。不需要用户操作。2012 - 05年……服务器本地连接提供程序已经准备好接受[\]上的连接。管道\ \ SQLLocal \ SQLEXPRESS]。2012 - 05年……服务器本地连接提供程序已经准备好接受[\]上的连接。管道\ \查询该SQLEXPRESS美元\ sql \]。2012 - 05年……服务器正在监听[:1 49164]。2012 - 05年……服务器正在监听[127.0.0.1 49164]。2012 - 05年……SQL Server现在已经为客户端连接做好了准备。这是一个信息信息;不需要用户操作。

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

请告诉我们你没有看到哪一行,第二行写的是什么?

#2


0  

If You have installed VS2008 then re-install sqlexpress2005 part once more or additionally you need to install that one then it will automatically fix its server name.

如果您已经安装了VS2008,那么重新安装sqlexpress2005的一部分,或者您需要安装它,然后它将自动修复它的服务器名称。

#3


0  

Make sure you have enabled the client protocols using the SQL Server Configuration Manager.

确保使用SQL Server Configuration Manager启用了客户端协议。