freeTDS not using its config

后端 未结 5 1829
执念已碎
执念已碎 2020-12-02 16:13

I\'ve decided to use FreeTDS driver and unixODBC to manage the PDO connection between my LAMP-based app with a remote MsSQL database. unfortunately it appears that the drive

相关标签:
5条回答
  • 2020-12-02 16:30

    Instead of connecting to an IP, try to connect to the name of the configuration section? For example:

    isql -v MSSQL
    
    0 讨论(0)
  • 2020-12-02 16:53

    I spent a long time today debugging a similar problem. I had set "TDS version" in freetds.conf but it was not being used in my ODBC connection. After reading the freetds source code (connectparams.c:odbc_parse_connect_string) I discovered that:

    • If your connection string uses "SERVER=" then both freetds.conf and odbc.ini are ignored
    • If your connection string uses "SERVERNAME=" then the settings in the appropriate freetds.conf server are used
    • If your connection string uses "DSN=" then the settings in the appropriate odbc.ini DSN are used

    odbcinst.ini is a red herring. FreeTDS never checks that for settings.

    The settings you specify in the connection string are always respected. It also always respects the environment variables like TDSVER.

    0 讨论(0)
  • 2020-12-02 16:53

    The initial TDSVER=7.0 issue was resolved by adding the following at the end of my odbc.ini file:

    [Default]
    Driver=/usr/local/lib/libtdsodbc.so
    
    0 讨论(0)
  • 2020-12-02 16:54

    My gut instinct is you need to change your tds version = 7.0 to tds version = 8.0 in your freetds.conf and odbc.ini files AND you need something in your odbcinst.ini file. Here's what I've got working on an Ubuntu 12.04 server talking to a remote MSSQL server:

    freetds.conf

    # Define a connection to the MSSQL server.
    [mssql]
        host = myserver
        port = 1433
        tds version = 8.0
    

    odbc.ini

    # Define a connection to the MSSQL server.
    # The Description can be whatever we want it to be.
    # The Driver value must match what we have defined in /etc/odbcinst.ini
    # The Database name must be the name of the database this connection will connect to.
    # The ServerName is the name we defined in /etc/freetds/freetds.conf
    # The TDS_Version should match what we defined in /etc/freetds/freetds.conf
    [mssql]
    Description             = MSSQL Server
    Driver                  = freetds
    Database                = MyDB
    ServerName              = myserver
    TDS_Version             = 8.0
    

    odbcinst.ini

    # Define where to find the driver for the Free TDS connections.
    [freetds]
    Description     = MS SQL database access with Free TDS
    Driver          = /usr/lib/i386-linux-gnu/odbc/libtdsodbc.so
    Setup           = /usr/lib/i386-linux-gnu/odbc/libtdsS.so
    UsageCount      = 1
    
    0 讨论(0)
  • 2020-12-02 16:54

    I experienced this exact same problem, but my config was already correctly set up. The problem was that the TDS versions that freetds.conf recognizes has changed in newer versions, but apparently the old versions still work in the TDSVER environment variable. Once I set the version in the config files to 7.1 rather than 8.0 everything started working.

    0 讨论(0)
提交回复
热议问题