0

I can connect from my Ubuntu 20.04 VM to my Azure SQL database with:

TDSVER=7.3 tsql -H mysubdomain.database.windows.net -U un -P pw -p 1433

I want to get this working with freetds.conf, but it's failing, and I'm not sure why; here's what I'm trying:

tsql -S db_from_conf -U un -P pw

With freetds.conf containing:

[db_from_conf]
    host = mysubdomain.database.windows.net
    port = 1433
    tds version = 7.3

The 2nd call fails with:

Msg 40532 (severity 20, state 1) from db_from_conf:
    "Cannot open server "db_from_conf" requested by the login.  The login failed."
Error 20002 (severity 9):
    Adaptive Server connection failed
There was a problem connecting to the server

Here are the results for 'tsql -C':

Compile-time settings (established with the "configure" script)
                        Version: freetds v1.1.6
         freetds.conf directory: /etc/freetds
 MS db-lib source compatibility: no
    Sybase binary compatibility: yes
                  Thread safety: yes
                  iconv library: yes
                    TDS version: auto
                          iODBC: no
                       unixodbc: yes
          SSPI "trusted" logins: no
                       Kerberos: yes
                        OpenSSL: no
                         GnuTLS: yes
                           MARS: yes

How are these different, and how can I get this working?

Crag
  • 1,723
  • 17
  • 35
  • 1
    Unfortunately, no. The issue was that Azure SQL requires different connect parameters than regular SQL Server instances. – Crag Aug 12 '21 at 18:06

1 Answers1

0

Try setting the TDS versions that freetds.conf recognizes in the config files to 7.1 or 8.0. In some users the problem was that the TDS versions that freetds.conf recognizes had changed in newer versions. Please check FreeTDS Version 1.3 Release 4 Jun 2021.

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

Your freetds.conf looks fine, remeber, the ServerName is the name you defined in /etc/freetds/freetds.conf and the TDS_Version should match what you defined in /etc/freetds/freetds.conf

example command:

 tsql -S 'DNS name' -U devuser 

or

 isql -v DNS Name User 'Password'

First install the following packages:

sudo apt-get install unixodbc unixodbc-dev freetds-dev tdsodbc

and configure freetds as follows:

--- /etc/freetds/freetds.conf ---
[TS]
host = SERVER
port = 1433
tds version = 7.0
client charset = UTF-8

If you need an odbc connection, you can configure odbcinst.ini as follows:

--- /etc/odbcinst.ini ---
[FreeTDS]
Description = FreeTDS
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
FileUsage = 1
CPTimeout =
CPResuse  =
client charset = utf-8

and odbc.ini as follows:

--- /etc/odbc.ini ---
[TS]
Description = "test"
Driver = FreeTDS
Servername = SERVER
Server = SERVER
Port = 1433
Database = DBNAME
Trace = No

Use this command to confirm your instance / server config:

tsql -LH servername

Remember you can only specify an instance OR a port, not both.

Once you confirmed your settings use this command to connect to the server and open an interactive prompt from which you can run SQL commands on the server:

tsql -S servername -U username -P password

Remember this user should be created on the DB server itself and have proper permissions to access your DB.

Note: If the issue still persists, in some cases the problem arose because of indents in the config file. So in /etc/odbc.ini, remove all indents and try again.

KarthikBhyresh-MT
  • 4,560
  • 2
  • 5
  • 12