0

正如我所提到的,我还没有设法将容器连接到 SQL Operations Studio。

我正在使用 docker compose 挂载容器,这是正确创建的,但是当我在 SQL Server Operations Studio 中输入凭据时,它没有连接。

码头工人-compose.yml

version: '3'
services: 
  mssqllinux:
    image:  microsoft/mssql-server-linux:2017-latest

    env_file: 
      - ./docker.env
    ports:
      - "1433:1433"

docker.env

sa_password=RUc@ysd@f_P*yq4é
ACCEPT_EULA=Y
MSSQL_PID=Express

λ docker-compose ps

              Name                     Command           State           Ports
    -----------------------------------------------------------------------------------
    sqlserlinux_mssqllinux_1   /opt/mssql/bin/sqlservr   Up      0.0.0.0:1433->1433/tcp

联系:


连接设置

错误:


错误信息

错误跟踪:


System.Data.SqlClient.SqlException (0x80131904): 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) ---> System.ComponentModel.Win32Exception (53): No se ha encontrado la ruta de acceso de la red
   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.<>c__DisplayClass22_0.<TryGetConnection>b__0(Task`1 _)
   at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection.ReliableSqlConnection.<>c__DisplayClass28_0.<<OpenAsync>b__0>d.MoveNext() in D:\a\1\s\src\Microsoft.SqlTools.ServiceLayer\Connection\ReliableConnection\ReliableSqlConnection.cs:line 298
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.SqlTools.ServiceLayer.Connection.ConnectionService.TryOpenConnection(ConnectionInfo connectionInfo, ConnectParams connectionParams) in D:\a\1\s\src\Microsoft.SqlTools.ServiceLayer\Connection\ConnectionService.cs:line 542
ClientConnectionId:00000000-0000-0000-0000-000000000000
Error Number:53,State:0,Class:20
4

1 回答 1

2

您可以尝试几个步骤。

首先要记住,虽然你是在windows里面,但是数据库服务器其实是在linux里面的,而且linux是超级区分大小写的系统。因此,请确保您的用户名是SA 或 sa

第二件事是,在服务器和端口值中,使用逗号 (,) 而不是冒号 (:),如下所示 在此处输入图像描述

第三,如果上述步骤对您不起作用,请首先确保您可以使用 SQLCMD 工具访问服务器。您可以关注此微软文档以获取详细信息。成功登录数据库后,您可以在 SQL Operations Studio 窗口中重用服务器值和凭据。

希望这可以帮助。

于 2018-06-24T10:44:15.763 回答