摘要::tsql
连接而isql
未连接。
详细信息:我已经尝试了所有可以找到的官方安装指南和Stack Overflow问题,但没有一个能让人高兴。我正在尝试使用pyodbc
从我的Mac(Mohave)和最终的Xubuntu 16.04虚拟机连接到MS SQL Server数据库。在进入Python之前,我只想对连接进行故障排除。问题是,我看到的大多数文档都缺少重要的细节,例如“我应该在用户名和密码中使用引号吗?”。或者,“我应该在用户名中包含域吗?”如果我应该在域中添加用户名,“我是否应该转义反斜杠字符?”
这是我当前的设置:tsql -C
产生
Compile-time settings (established with the "configure" script)
Version: freetds v1.1.11
freetds.conf directory: /usr/local/etc
MS db-lib source compatibility: no
Sybase binary compatibility: yes
Thread safety: yes
iconv library: yes
TDS version: 7.3
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: yes
OpenSSL: yes
GnuTLS: no
MARS: yes
/usr/local/etc/freetds.conf
的内容是:
#
# This file is installed by FreeTDS if no file by the same
# name is found in the installation directory.
#
# For information about the layout of this file and its settings,
# see the freetds.conf manpage "man freetds.conf".
# Global settings are overridden by those in a database
# server specific section
[global]
# TDS protocol version
tds version = auto
# Whether to write a TDSDUMP file for diagnostic purposes
# (setting this to /tmp is insecure on a multi-user system)
; dump file = /tmp/freetds.log
; debug flags = 0xffff
# Command and connection timeouts
; timeout = 10
; connect timeout = 10
# To reduce data sent from server for BLOBs (like TEXT or
# IMAGE) try setting 'text size' to a reasonable limit
; text size = 64512
# If you experience TLS handshake errors and are using openssl,
# try adjusting the cipher list (don't surround in double or single quotes)
# openssl ciphers = HIGH:!SSLv2:!aNULL:-DH
# A typical Sybase server
[egServer50]
host = symachine.domain.com
port = 5000
tds version = 5.0
# A typical Microsoft server
[egServer73]
host = ntmachine.domain.com
port = 1433
tds version = 7.3
[my_server]
host = my_server
port = 1433
tds version = 7.3
my_server
是我要连接的服务器。
命令tsql -S my_server -U domain\\username -P password
(在任何地方都没有引号)可以很好地连接,并显示结果
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
1>
FreeTDS太多了。对于ODBC方面,首先请注意,显然已经为ODBC设置了FreeTDS,因为它在unixodbc: yes
的结果中显示了tsql -C
。我的/etc/odbcinst.ini
文件包含:
[FreeTDS]
Description=FreeTDS Driver for Linux & MSSQL
Driver=/usr/local/lib/libtdsodbc.so
Setup=/usr/local/lib/libtdsodbc.so
UsageCount=1
我的/etc/odbc.ini
文件包含
[my_server]
Description = "The Location of the EOAM_RA Database"
Driver = FREETDS
Trace = Yes
TraceFile = /tmp/sql.log
Database = my_database
Servername = my_server
UserName = domain\\username
Password = password
Port = 1433
Protocol = 7.3
ReadOnly = No
RowVersioning = No
ShowSystemTables = No
ShowOidColumn = No
FakeOidIndex = No
但是,当我尝试使用任何版本的isql -v my_server username password
时,我都会感到恐惧和无济于事
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[01000][unixODBC][FreeTDS][SQL Server]Unknown host machine name.
[ISQL]ERROR: Could not SQLConnect
因此,尽管我当然希望对所有设置都具有正确的设置,以便我可以通过isql
并最终通过pyodbc
进行连接,但是如果我能得到以下答案的话,这也将大有帮助问题:
非常感谢您的光临!
答案 0 :(得分:1)
在freetds.conf文件中为SQL Server使用完全限定的域名(fqdn)之后,您是否尝试过连接:
[my_server]
host = my_server.<yourdomain.example>
port = 1433
tds version = 7.3