简体   繁体   English

无法连接到在 docker 上运行的 SQL 服务器

[英]Can't connect to SQL SERVER running on docker

I've installed a sqlserver docker container and it seems that the instalation its fine, as shown bellow:我已经安装了一个 sqlserver docker 容器,看起来安装正常,如下所示: 在此处输入图像描述 I've setup the server using this command:我已经使用此命令设置了服务器:

docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=<@MystrongPassword1" -p 1433:1433 --name sql1 --hostname sql1 -d mcr.microsoft.com/mssql/server:2022-latest

The problem is: I'm trying to create a connection on Azure Data Studio, this is the configuration I'm using问题是:我正在尝试在 Azure Data Studio 上创建连接,这是我正在使用的配置在此处输入图像描述

When I click the "Connect" button, it doesnt connect and the below errors are shown:当我单击“连接”按钮时,它没有连接,并显示以下错误:

在此处输入图像描述 When the first error apears, I click the "enable trust certificate" button, and then the second error pop up appears and the connection fails:当第一个错误出现时,我点击“启用信任证书”按钮,然后出现第二个错误弹出连接失败:

在此处输入图像描述

The error details:错误详情:


Microsoft.Data.SqlClient.SqlException (0x80131904): Login failed for user 'sa'.
   at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at Microsoft.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at Microsoft.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
   at Microsoft.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
   at Microsoft.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
   at Microsoft.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
   at Microsoft.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken, DbConnectionPool pool)
   at Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   at Microsoft.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
   at Microsoft.Data.ProviderBase.DbConnectionFactory.<>c__DisplayClass48_0.<CreateReplaceConnectionContinuation>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 ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection.ReliableSqlConnection.<>c__DisplayClass30_0.<<OpenAsync>b__0>d.MoveNext() in D:\a\_work\1\s\src\Microsoft.SqlTools.ManagedBatchParser\ReliableConnection\ReliableSqlConnection.cs:line 312
--- End of stack trace from previous location ---
   at Microsoft.SqlTools.ServiceLayer.Connection.ConnectionService.TryOpenConnection(ConnectionInfo connectionInfo, ConnectParams connectionParams) in D:\a\_work\1\s\src\Microsoft.SqlTools.ServiceLayer\Connection\ConnectionService.cs:line 666
ClientConnectionId:cbab63a5-c831-442e-b117-eb024e6f16bf
Error Number:18456,State:1,Class:14

I just deleted it all and created all the same but this time it worked我只是将其全部删除并创建了所有相同但这次它有效

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法从 Docker (Linux) 中运行的 ASP.NET Core 连接到 SQL Server 命名实例 - Can't connect to SQL Server named instance from ASP.NET Core running in Docker (Linux) 无法从运行在 docker 上的 .net 核心应用连接到 SQL Server express - Can't connect to SQL Server express from .net core app running on docker 无法连接到在Docker容器中运行的SQL Server实例 - Can not connect to instance of SQL Server that is running in Docker container Docker 容器无法连接到远程服务器上的 SQL 服务器 - Docker container can't connect to SQL Server on a remote server 为什么我的node js脚本连接不上我在docker中运行的mssql数据库,但是微软SQL服务器管理可以 - Why can't my node js script connect to my mssql database running in docker, but Microsoft SQL Server Management can 无法从 Docker 容器连接到外部 SQL 服务器 - Can't Connect to External SQL Server From Docker Container 无法连接到travis中docker内的SQL Server数据库 - Can't connect to SQL Server database inside docker in travis Docker容器中的.Net Core应用无法连接到SQL Server - .Net Core app in docker container can't connect to SQL Server 使用 docker 无法连接到 Azure SQL 服务器 - Can't connect to Azure SQL server using docker 无法通过 docker 连接到 SQL 服务器数据库 - Can't connect to SQL Server database via docker
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM