Mac M1 在 Docker 上运行 MS SQL,无法从 Azure Data Studio 连接

发布于 2025-01-09 16:14:54 字数 4586 浏览 0 评论 0原文

环境:MacBook Pro - 芯片:Apple M1 Pro、macOS Monterey 12.2.1

如何在 Mac M1 上运行 docker MS SQL(任何版本)并从 Azure Data Studio 连接?

我能够创建azure-sql-edge 的 docker 映像。 Pod 运行正常。

信息:从 127.0.0.1:57588 到 127.0.0.1:1431 打开的连接

YAML 文件附在此处。

Azure Data Studio 错误:

错误:服务器为 localhost 1433
建立与 SQL Server 的连接时发生与网络相关或特定于实例的错误。找不到服务器或无法访问服务器。验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接。 (提供程序:TCP 提供程序,错误:35 - 捕获内部异常)

错误:服务器作为本地主机,没有端口号
与服务器成功建立连接,但在登录前握手期间发生错误。 (提供程序:TCP 提供程序,错误:0 - 40034080)

YAML:

apiVersion:apps/v1 种类:部署 元数据: 名称:mssql-depl 规格: 副本:1 选择器: 匹配标签: 应用程序:mssql 模板: 元数据: 标签: 应用程序:mssql 规格: 容器: - 名称:mssql 图片:mcr.microsoft.com/azure-sql-edge 端口: - 集装箱端口:1433 环境: - 名称:MSSQL_PID 值:“开发者” - 名称:ACCEPT_EULA 值:“Y” - 名称:MSSQL_SA_PASSWORD 值来自: 秘密密钥参考: 名称:mssql 键:MSSQL_SA_PASSWORD 体积安装: - 挂载路径:var/opt/mssql/data 名称:mssqldb 卷: - 名称:mssqldb 持久卷声明: 声明名称:mssql-claim

api版本:v1 种类: 服务 元数据: 名称:mssql-clusterip-srv 规格: 类型:集群IP 选择器: 应用程序:msql 端口:

  • 名称:mssql 协议: TCP 端口:1433 目标端口:1433

api版本:v1 种类: 服务 元数据: 名称:mssql-负载均衡器 规格: 类型:负载均衡器 选择器: 应用程序:msql 端口:

  • 协议: TCP 端口:1433 targetPort:1433

来自 Azure Data Studio 的详细错误:
Microsoft.Data.SqlClient.SqlException (0x80131904):已成功与服务器建立连接,但在登录前握手期间发生错误。 (提供者:TCP 提供者,错误:0 - 未定义错误:0) 在Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException异常,布尔breakConnection,Action1wrappCloseInAction)在Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj,布尔callerHasConnectionLock,布尔asyncClose)在Microsoft.Data.SqlClient.TdsParserStateObject.ThrowExceptionAndWarning(布尔调用者HasConnectionLock,布尔asyncClose)在Microsoft.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj,UInt32错误)在Microsoft.Data.SqlClient.TdsParserStateObject.ReadSniSyncOverAsync()在Microsoft.Data.SqlClient.TdsParserStateObject.TryReadNetworkPacket() 在 Microsoft.Data.SqlClient.TdsParser.ConsumePreLoginHandshake(布尔加密、布尔 trustServerCert、布尔集成安全性、布尔& marsCapable、布尔& fedAuthRequired)在 Microsoft.Data.SqlClient.TdsParser.Connect(服务器信息Microsoft.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo,String newPassword,SecureString newSecurePassword)处的serverInfo,SqlInternalConnectionTds connHandler,布尔ignoreSniOpenTimeout,Int64计时器Expire,布尔加密,布尔trustServerCert,布尔integratedSecurity,布尔withFailover,SqlAuthenticationMethod authType) Microsoft.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo、String newPassword、SecureString newSecurePassword、布尔redirectedUserInstance、SqlConnectionString connectionOptions、SqlCredential 凭据、TimeoutTimer 超时)处的布尔ignoreSniOpenTimeout、TimeoutTimer 超时、布尔withFailover) Microsoft.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer超时,SqlConnectionString connectionOptions,SqlCredential凭据,字符串newPassword,SecureString newSecurePassword,布尔redirectedUserInstance)在Microsoft.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity标识,SqlConnectionString) Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey、对象 poolGroupProviderInfo、DbConnectionPool 池、DbConnection owningConnection、DbConnectionOptions userOptions)位于 Microsoft.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection、DbConnectionPoolGroup poolGroup、DbConnectionOptions userOptions) Microsoft.Data.ProviderBase.DbConnectionFactory.<>c__DisplayClass48_0.b__0(任务1 _) 在 System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke() 在 System.Threading.ExecutionContext.RunInternal(ExecutionContextexecutionContext,ContextCallback 回调,对象状态) --- 先前位置的堆栈跟踪结束 --- 在 System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- 先前位置的堆栈跟踪结束 --- 在 D:\a\1\s\src\Microsoft.SqlTools.ManagedBatchParser\ReliableConnection\ReliableSqlConnection 中的 Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection.ReliableSqlConnection.<>c__DisplayClass30_0.d.MoveNext() 处。 CS:第 316 行 --- 先前位置的堆栈跟踪结束 --- 在 D:\a\1\s\src\Microsoft.SqlTools.ServiceLayer\Connection\ConnectionService.cs 中的 Microsoft.SqlTools.ServiceLayer.Connection.ConnectionService.TryOpenConnection(ConnectionInfo connectionInfo, ConnectParams connectionParams):第 602 行 客户端连接 ID:81d69633-9dd4-4088-88d4-5327bb824852

Environment: MacBook Pro - Chip: Apple M1 Pro, macOS Monterey 12.2.1

How do I run a docker MS SQL (any version) on Mac M1 and connect from Azure Data Studio?

I was able to create a docker image of azure-sql-edge. Pod is running OK.

INFO: Connection opened from 127.0.0.1:57588 to 127.0.0.1:1431

YAML file is attached here.

Azure Data Studio Error:

Error: server as localhost 1433
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: TCP Provider, error: 35 - An internal exception was caught)

Error: server as localhost without Port number
A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - 40034080)

YAML:

apiVersion: apps/v1
kind: Deployment
metadata:
name: mssql-depl
spec:
replicas: 1
selector:
matchLabels:
app: mssql
template:
metadata:
labels:
app: mssql
spec:
containers:
- name: mssql
image: mcr.microsoft.com/azure-sql-edge
ports:
- containerPort: 1433
env:
- name: MSSQL_PID
value: "Developer"
- name: ACCEPT_EULA
value: "Y"
- name: MSSQL_SA_PASSWORD
valueFrom:
secretKeyRef:
name: mssql
key: MSSQL_SA_PASSWORD
volumeMounts:
- mountPath: var/opt/mssql/data
name: mssqldb
volumes:
- name: mssqldb
persistentVolumeClaim:
claimName: mssql-claim

apiVersion: v1
kind: Service
metadata:
name: mssql-clusterip-srv
spec:
type: ClusterIP
selector:
app: msql
ports:

  • name: mssql
    protocol: TCP
    port: 1433
    targetPort: 1433

apiVersion: v1
kind: Service
metadata:
name: mssql-loadbalancer
spec:
type: LoadBalancer
selector:
app: msql
ports:

  • protocol: TCP
    port: 1433
    targetPort: 1433

Detailed error from the Azure Data Studio:
Microsoft.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - Undefined error: 0)
at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at Microsoft.Data.SqlClient.TdsParserStateObject.ThrowExceptionAndWarning(Boolean callerHasConnectionLock, Boolean asyncClose) at Microsoft.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error) at Microsoft.Data.SqlClient.TdsParserStateObject.ReadSniSyncOverAsync() at Microsoft.Data.SqlClient.TdsParserStateObject.TryReadNetworkPacket() at Microsoft.Data.SqlClient.TdsParser.ConsumePreLoginHandshake(Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean& marsCapable, Boolean& fedAuthRequired) at Microsoft.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover, SqlAuthenticationMethod authType) 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(Task1 _)
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.<b__0>d.MoveNext() in D:\a\1\s\src\Microsoft.SqlTools.ManagedBatchParser\ReliableConnection\ReliableSqlConnection.cs:line 316
--- End of stack trace from previous location ---
at Microsoft.SqlTools.ServiceLayer.Connection.ConnectionService.TryOpenConnection(ConnectionInfo connectionInfo, ConnectParams connectionParams) in D:\a\1\s\src\Microsoft.SqlTools.ServiceLayer\Connection\ConnectionService.cs:line 602
ClientConnectionId:81d69633-9dd4-4088-88d4-5327bb824852

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

掀纱窥君容 2025-01-16 16:14:54

对于“连接详细信息”下的“服务器”字段,输入“localhost, 1433”。

For the "Server" field under "Connection Details", enter "localhost, 1433".

垂暮老矣 2025-01-16 16:14:54

以下链接应该有助于在基于 Mac Arm 的计算机上对 SQLServer 进行 Docker 化。

docker pull mcr.microsoft.com/azure-sql-edge

这将在 Linux 上安装 SQLServer。
从那里您可以尝试使用 Azure Data Studio 访问数据库。

详细信息在下面的网址中。
https:// medium.com/geekculture/docker-express-running-a-local-sql-server-on-your-m1-mac-8bbc22c49dc9

The following link should help on dockerizing SQLServer on Mac Arm-based machine.

docker pull mcr.microsoft.com/azure-sql-edge

This would install SQLServer on Linux.
From there you can try to access the database using Azure Data Studio.

Details are in the url below.
https://medium.com/geekculture/docker-express-running-a-local-sql-server-on-your-m1-mac-8bbc22c49dc9

羅雙樹 2025-01-16 16:14:54

不确定这是否有帮助,但如果您尝试连接到本地服务器,请使用: localhost 作为服务器名称。

我遵循了这个,终于让它与 azure、docker 一起工作:
https://medium.com/geekculture/how-to-install-sql-server-in-mac- m1-41121e110214
天蓝色的SQL连接

Not sure if this helps but use: localhost as the name of the server if you are trying to connect to a local server.

I followed this and I finally got it to work with azure, docker:
https://medium.com/geekculture/how-to-install-sql-server-in-mac-m1-41121e110214
azure sql connection

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文