【问题标题】:How to install freetds in Linux?如何在 Linux 中安装 freetds?
【发布时间】:2016-01-25 07:15:09
【问题描述】:

我正在尝试从 Ubuntu 连接到 MSSQL 服务器。我已经像建议的here 一样安装了freetds。

但是,当我尝试配置 /etc/odbc.ini 并输入驱动程序路径时,我在位置 /usr/local/freetds/lib/libtdsodbc.so 没有驱动程序。

有人可以帮我安装 freetds 并配置 odbc 以使用它吗? *edit1:我在 /usr/lib/x86_64-linux-gnu/odbc 中找到了 libtdsodbc.so。我应该使用那个驱动程序/路径吗?

【问题讨论】:

标签: sql-server linux freetds unixodbc


【解决方案1】:

我创建了一个 Vagrant 盒子,这里有一个完整的安装示例:https://github.com/FlipperPA/django-python3-vagrant/

...但这里是基本步骤。

# Install pre-requesite packages
sudo apt-get install unixodbc unixodbc-dev freetds-dev freetds-bin tdsodbc

将 odbcinst.ini 指向 /etc/odbcinst.ini 中的驱动程序:

[FreeTDS]
Description = v0.91 with protocol v7.2
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so

在 odbc.ini 中创建您的 DSN:

[dbserverdsn]
Driver = FreeTDS
Server = dbserver.domain.com
Port = 1433
TDS_Version = 7.2

...以及您在 freetds.conf 中的 DSN:

[global]
    # TDS protocol version, use:
    # 7.3 for SQL Server 2008 or greater (tested through 2014)
    # 7.2 for SQL Server 2005
    # 7.1 for SQL Server 2000
    # 7.0 for SQL Server 7
    tds version = 7.2
    port = 1433

    # 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

    # If you get out-of-memory errors, it may mean that your client
    # is trying to allocate a huge buffer for a TEXT field.  
    # Try setting 'text size' to a more reasonable limit 
    text size = 64512

# A typical Microsoft server
[dbserverdsn]
    host = dbserver.domain.com
    port = 1433
    tds version = 7.2

完成此操作后,您可以通过尝试连接 tsql(测试 FreeTDS 层)和 isql(通过 FreeTDS 堆栈用于 unixODBC)来测试您的连接。

【讨论】:

  • 我是新手。我想我应该用我的服务器的 IP 更改Server = dbserver.domain.com?这是我使用 tsql tsql -S dbserverdsn 的方式还是应该在那里写 IP?当我使用tsql -S dbserverdsn 我得到Error 100 (severity 11): unrecognized msgno Error 20009 (severity 9):Unable to connect: Adaptive Server is unavailable or does not exist OS error 111, "Connection refused" There was a problem connecting to the server
  • 应该有 tsql -S dbserverdsn
  • 我用tsql -C检查了tds版本,发现它是4.2。我用 4.2 替换了上面的 7.2,这似乎删除了 msgno error
【解决方案2】:

通过apt-get 获得的版本是一个非常旧的版本。获取更新版本:

sudo apt-get install wget
sudo apt-get install build-essential
sudo apt-get install libc6-dev

# find latest version of FreeTDS ftp://ftp.freetds.org/pub/freetds/stable/

wget ftp://ftp.freetds.org/pub/freetds/stable/freetds-1.2.tar.gz
tar -xzf freetds-1.2.tar.gz
cd freetds-1.2
./configure --prefix=/usr/local --with-tdsver=7.3
sudo make
sudo make install

【讨论】:

  • 仅供参考:当前稳定版本为1.12 (2019/07)。
  • 非常有用,谢谢!
【解决方案3】:

在 freedts.conf 中

[Server80]
        host = example.com
        port = 1433
        tds version = 8.0
        client charset = UTF-8

在 odbc.ini 中

[MSSQL8]
Driver          = FreeTDS
Description     = Sybase JDBC Server
Trace           = No
Servername      = Server80
Database        = DBNAME
UID             = sa
ClientCharset   = UTF-8

在 odbcinst.ini 中

[FreeTDS]
Description=v0.63 with protocol v8.0
Driver=/usr/lib/i386-linux-gnu/odbc/libtdsodbc.so
UsageCount=2

【讨论】:

  • 它似乎与 sudo apt install -y freetds-bin (!) 合作
猜你喜欢
  • 2012-08-25
  • 2018-01-30
  • 2018-10-27
  • 1970-01-01
  • 2013-09-18
  • 2015-05-23
  • 2017-01-13
  • 1970-01-01
  • 2016-02-12
相关资源
最近更新 更多