1

I'm trying to connect to my sql server database but it's not working.

The freetds is working, see the command:

tsql -S myserver.database.windows.net -U myuser -P mypassword

output:

locale is "C/UTF-8/C/C/C/C"
locale charset is "UTF-8"
using default charset "UTF8"
1> 

but when I try to run the command isql, it returns me error.

command:

isql -v MYSERVER myuser mypassword

output:

[IM002][unixODBC][Driver Manager]Data source name not found, and no default driver specified
[ISQL]ERROR: Could not SQLConnect

My files:

freetds.conf:

#   $Id: freetds.conf,v 1.12 2007-12-25 06:02:36 jklowden Exp $
#
# This file is installed by FreeTDS if no file by the same 
# name is found in the installation directory.  
#
# For information about the layout of this file and its settings, 
# see the freetds.conf manpage "man freetds.conf".  

# Global settings are overridden by those in a database
# server specific section
[global]
    # TDS protocol version
    tds version = 8.0

    # 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

    # If you experience TLS handshake errors and are using openssl,
    # try adjusting the cipher list (don't surround in double or single quotes)
    # openssl ciphers = HIGH:!SSLv2:!aNULL:-DH

[MYSERVER]
   host = myserver.database.windows.net
   port = 1433
   tds version = 8.0
   client charset = UTF8

odbcinst.ini:

[FreeTDS]
Description = FreeTDS
Driver      = /usr/local/lib/libtdsodbc.so
Setup       = /usr/local/lib/libtdsodbc.so
UsageCount  = 1
Trace       = Yes
TraceFile   = /Users/giorgecaique/Documents/sql.log

odbc.ini:

[MYSERVER]
Description = MYSERVER
Driver      = FreeTDS
Database    = mydatabase
Server      = myserver.database.windows.net
UserName    = myuser
Password    = mypassword
TDS_Version = 8.0

Can anyone help me? I already saw a lot of tutorials of how to solve this, but none of it worked for me.

Giorge Caique
  • 199
  • 1
  • 1
  • 16

3 Answers3

0

In odbc.ini file, you need a Servername attribute which points to the name of the DSN in freetds.conf. Also, 8.0 is not a valid version (long story, see the docs), and it is UTF-8 not UTF8. For example:

freetds.conf:

[MYSERVER]
   host = myserver.database.windows.net
   port = 1433
   tds version = 7.1
   client charset = UTF-8

And then in odbc.ini:

[MYSERVER]
Description = MYSERVER
Driver      = FreeTDS
Database    = mydatabase
Servername  = MYSERVER
UserName    = myuser
Password    = mypassword
TDS_Version = 7.1

Good luck!

FlipperPA
  • 13,607
  • 4
  • 39
  • 71
0

Have you checked that you have the library /usr/local/lib/libtdsodbc.so?

I ran into a similar error. I fixed my error following this guide at link.

I believe you may not have installed the drivers for freetds, which you can install via Homebrew with: $ brew install freetds --with-unixodbc

XValidated
  • 981
  • 8
  • 12
0

Did you try emehex's answer from here:

Can't open lib 'ODBC Driver 13 for SQL Server'? Sym linking issue?

sudo ln -s /usr/local/etc/odbcinst.ini /etc/odbcinst.ini
sudo ln -s /usr/local/etc/odbc.ini /etc/odbc.ini
Ajay2707
  • 5,690
  • 6
  • 40
  • 58
jcbake
  • 1