Connect to MS SQL Server

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.

你可能感兴趣的:(sql,linux,SQL Server)