Connect to MS SQL Server

本文介绍如何使用Freetds在Linux环境下连接MSSQL Server。通过安装Freetds及UnixODBC,并配置相关文件如freetds.conf和odbc.ini来实现跨平台数据库连接。文中还提供了测试连接的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Freetds is used to connect MS SQL Server in linux. and freetds depends on UnixODBC. In fedora, execute

yum -y freetds, freetds-devel

 and freetds, unixodbc and freetds-devel will be installed. freetds-devel provides the driver.

Then, configure freetds: (The configuration file is /etc/freetds.conf)

[MSServer]
        host=172.29.128.204

        port=1433
        tds version=7.0

 Configure unixodbc

  1. /etc/odbcinst.ini
    [MSSQLServer
    ]
    Description=TDS Driver
    Driver=/usr/lib/libtdsodbc.so
    Setup=/usr/lib/libtdsodbc.so
    Trace=Yes
    TraceFile=/tmp/freetds.log
    FileUsage=1
  2. /etc/odbc.ini
    [MSSQLServer]
    Driver = MSSQLServer
    
    Description = MS SQL Server Data Source
    Trace = Yes
    TraceFile = /tmp/mstext.log
    Servername = 172.29.128.204
    
    Database = durango_60
    Port = 1433
     Notice that Driver refers to odbcinst.ini and Servername is defined in freetds.conf.

At last, we can test by executing following commands:

isql MSSQLServer user password

 Driver may be in different directory in different version. Make sure the path in the configuration file is valid.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值