我想从WSL2连接到远程SQL Server,但是由于某种原因,我一直遇到错误。我尝试使用Windows主机计算机连接,没有任何问题。
〜/.odbc.ini
[MSSQLTest]
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.9.so.1.1
server=tcp:server,port
Database=Databasename
Trusted_Connection=yes
TrustServerCertificate=yes
[email protected]
pwd=password
odbcinst -j
unixODBC 2.3.7
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /home/test/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
错误
test@Desktop:/mnt/c/Users/test$ isql -v mssqltest
[S1000][unixODBC][Microsoft][ODBC Driver 17 for SQL Server]SSPI Provider: No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1000)
[S1000][unixODBC][Microsoft][ODBC Driver 17 for SQL Server]Cannot generate SSPI context
我在DSN中尝试了几种不同的变化,但没有任何变化。唯一改变的是错误消息。然后,我尝试安装 mssql-tools
使用 sqlcmd
,但是我遇到了类似的错误。
错误
test@DESKTOP:/mnt/c/Users/test$ sqlcmd -S server -U domain\\username -P password -G
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : SSL Provider: [error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:self signed certificate].
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish the connection.
我不知道上面的错误是什么意思。
test@desktop:/mnt/c/user/test $ sqlcmd -s ;受保护] -U域\用户名-P密码-G
SQLCMD:错误:SQL Server的Microsoft ODBC驱动程序17:SSL提供程序:[错误:1416F086:SSL例程:TLS_Process_Server_Certificate:证书验证验证失败:自签名证书:自签名证书]。
SQLCMD:错误:SQL Server的Microsoft ODBC驱动程序17:客户端无法建立连接。
我有类似的错误。如果我在DSN中更改某些内容,则会发现一个错误,说明否可用的kerberos凭据(默认缓存:fiel:/tmp/krb5cc_1000)。无法生成SSPI上下文。
我抬头抬起头来,尝试了在SO和其他网站上建议的许多不同的解决方案,但我似乎无法使其正常工作。但是,我可以ping服务器。
为什么这样做?为什么我的连接从Windows主机计算机起作用而不是WSL?我想念什么?
I want to connect to a remote SQL Server from WSL2, but I keep getting errors for some reason. I tried connecting using my Windows Host machine without any problem.
~/.odbc.ini
[MSSQLTest]
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.9.so.1.1
server=tcp:server,port
Database=Databasename
Trusted_Connection=yes
TrustServerCertificate=yes
[email protected]
pwd=password
odbcinst -j
unixODBC 2.3.7
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /home/test/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
Errors
test@Desktop:/mnt/c/Users/test$ isql -v mssqltest
[S1000][unixODBC][Microsoft][ODBC Driver 17 for SQL Server]SSPI Provider: No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1000)
[S1000][unixODBC][Microsoft][ODBC Driver 17 for SQL Server]Cannot generate SSPI context
I tried several different changes in the DSN, but none worked. The only thing that changed was the error messages. Then I tried installing mssql-tools
to use sqlcmd
, but I got similar errors.
Errors
test@DESKTOP:/mnt/c/Users/test$ sqlcmd -S server -U domain\\username -P password -G
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : SSL Provider: [error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:self signed certificate].
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish the connection.
I have no idea what the error above means.
test@DESKTOP:/mnt/c/Users/test$ sqlcmd -S [email protected] -U domain\username -P password -G
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : SSL Provider: [error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:self signed certificate].
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish connection.
I get a similar error. If I change something in the DSN, I get an error stating No kerberos credentials available (default cache: FIEL:/tmp/krb5cc_1000). Cannot generate SSPI context.
I looked up and tried many different solutions suggested on SO and other sites, but I can't seem to get it working. I can, however, ping the server.
Why is it doing this? Why does my connection work from my Windows Host machine but not WSL? What am I missing?
发布评论
评论(1)
我认为您的设置没有任何问题。您可能需要检查您的管理员是否允许SQL身份验证。然后使用SQLCMD检查它是否适合您。然后,您可能可以找出解决方案。
I don't think there's anything wrong with your setup. You might want to check if your admin allows SQL Authentication. Then use the sqlcmd to check if it works for you. You may be able to figure out the solution then.