从cygwin窗口连接到SQL Server超时,从DOS提示符下起作用

时间:2020-03-06 14:31:08  来源:igfitidea点击:

我可以从DOS命令窗口通过sqlcmd连接到我的SQL Server数据库,但不能从Cygwin窗口连接到SQL Server数据库。从DOS:

F:\Cygnus>sqlcmd -Q "select 'a test'" -S .\SQLEXPRESS

一个测试

(受影响的1行)

F:\Cygnus>

================================================== ==

从Cygwin:

$ sqlcmd -Q "select 'a test'" -S .\SQLEXPRESS
HResult 0x35, Level 16, State 1
 Named Pipes Provider: Could not
  open a connection to SQL Server [53]. Sqlcmd: Error: Microsoft SQL
  Native Client : An error has occurred while establishing a connection
  to the server. When connecting to SQL Server 2005, this failure may be
  caused by the fact that under the default settings SQL Server does not
  allow remote connections.. Sqlcmd: Error: Microsoft SQL Native Client
  : Login timeout expired.

解决方案

为此,我们可能需要允许远程连接,并提供完整的服务器名称,即SERVER \ SQLEXPRESS

cygwin的bash shell正在吃反斜杠。尝试加倍:

sqlcmd -Q "select 'a test'" -S .\SQLEXPRESS