【发布时间】:2016-07-14 19:46:01
【问题描述】:
我在 mac os x (yosemite) 上使用 freetds 0.95 连接到 SQL 服务器 [想要连接到本地数据库],但到目前为止我所有的尝试都失败了。
终端上的odbcinst -j 给了我以下信息:
unixODBC 2.3.2
DRIVERS............: /usr/local/Cellar/unixodbc/2.3.2_1/etc/odbcinst.ini
SYSTEM DATA SOURCES: /usr/local/Cellar/unixodbc/2.3.2_1/etc/odbc.ini
FILE DATA SOURCES..: /usr/local/Cellar/unixodbc/2.3.2_1/etc/ODBCDataSources
USER DATA SOURCES..: /Users/user/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
最初,我想连接到我的本地 sql 服务器。
下面是我的 freetds.conf 的摘录,位于/usr/local/etc/freetds.conf
# A typical Microsoft server
[#egServer70]
# host = ntmachine.domain.com
# port = 1433
# tds version = 7.0
[TITAN]
host = 127.0.0.1
port = 3306
tds version = 8.0
[testing]
host = 127.0.0.1
port = 1433
tds version = 8.0
我尝试使用 TDS 8.0 版,但连接仍然失败。
当我运行tsql -S TITAN -U root 或tsql -S testing -U root 时,我收到以下错误:
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Error 20002 (severity 9):
Adaptive Server connection failed
There was a problem connecting to the server
以下是:
odbcinst.ini 文件位于 /usr/local/Cellar/unixodbc/2.3.2_1/etc
[FreeTDS]
Description=Open source FreeTDS Driver
Driver=/usr/local/lib/libtdsodbc.so
UsageCount=1
odbc.ini 文件位于 /usr/local/Cellar/unixodbc/2.3.2_1/etc
[testing]
Driver=FreeTDS
Server=localhost
#Port=3306
#charset=UTF8
User=
Password=
#Database=admin
## can specify an actual database to each DSN
TDS_Version=8.0
[Default]
Driver=/usr/local/lib/libtdsodbc.so
到目前为止,我真的不知道我做错了什么,也许我在操作系统 freetds 上错误地安装了 odbc。请帮我解决这个问题。
【问题讨论】:
-
您使用的是 Mac OS/X,但您想在本地连接到 Microsoft SQL Server? Microsoft 的 SQL Server 仅在 Windows 上运行(目前),因此您无法在本地连接到它,除非在 VM 中运行 Windows,但这是完全不同的蠕虫罐。
-
我已经使用 Native 包在 Max OS 上安装了 MySQL。 dev.mysql.com/doc/refman/5.7/en/osx-installation-pkg.html
-
SQL 运行良好。当我尝试连接到 postgres 时,我也遇到了连接问题。我认为我错误地安装或配置了 odbc/freetds。
-
安装 MySQL 与 SQL Server 无关。这是两个完全不同的东西。
-
MySQL 不是 SQL Server; SQL Server 是 Microsoft 的数据库服务器。混乱就在于此。 FreeTDS 用于连接到 Microsoft SQL Server。我会给出答案的。
标签: sql-server macos pyodbc freetds rodbc