title: Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Data source name not found and no default driver specified
body: <p>Trying to use <code>sqlcmd</code> from <code>mssql-tools</code> package (loosly following the docs here: <a href="https://github.com/mkleehammer/pyodbc/wiki/Connecting-to-SQL-Server-from-RHEL-6-or-Centos-7" rel="nofollow noreferrer">https://github.com/mkleehammer/pyodbc/wiki/Connecting-to-SQL-Server-from-RHEL-6-or-Centos-7</a>) and seeing error</p>
  
  <blockquote>
    <p>Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Data source name not found and no default driver specified.</p>
  </blockquote>
  
  <p>even though I believe that both DSN and driver are specified (see below)</p>
  
  <pre class="lang-sh prettyprint-override"><code>[airflow@airflowetl ~]$
  [airflow@airflowetl ~]$
  [airflow@airflowetl ~]$ # trying to connect to DB via DSN (-S option)
  [airflow@airflowetl ~]$ /opt/mssql-tools/bin/sqlcmd -Q "select count(*) from MYTABLE" -D -S "MyMSSQLServer" -U "myuser" -P "mypass" -d mydb -W -h-1 -k
  Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Data source name not found and no default driver specified.
  [airflow@airflowetl ~]$
  [airflow@airflowetl ~]$
  [airflow@airflowetl ~]$ # checking odbc config files
  [airflow@airflowetl ~]# odbcinst -j
  unixODBC 2.3.7
  DRIVERS............: /etc/odbcinst.ini
  SYSTEM DATA SOURCES: /etc/odbc.ini
  FILE DATA SOURCES..: /etc/ODBCDataSources
  USER DATA SOURCES..: /root/.odbc.ini
  SQLULEN Size.......: 8
  SQLLEN Size........: 8
  SQLSETPOSIROW Size.: 8
  [airflow@airflowetl ~]$ cat /etc/odbc.ini 
  [MyMSSQLServer]
  Driver=ODBC Driver 17 for SQL Server
  Description=My MS SQL Server
  Trace=No
  Server=172.18.1.23
  
  [airflow@airflowetl ~]$ cat /etc/odbcinst.ini 
  
  [airflow@airflowetl ~]$ ls -lha /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.4.so.2.1 
  -rwxr-xr-x 1 root root 2.0M Sep 26 06:19 /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.4.so.2.1
  </code></pre>
  
  <p>Notice that <code>/etc/odbcinst.ini</code> is blank when (I think) it should corespond to Driver entries in the <code>odbc.ini</code> file. Should I just fill this in manually? Why does it not auto-fill in this case (as it has done on other machines where I have set up odbc)?</p>
  
  <p>Not much experience with ODBC setup, so not sure what to make of this error. Anyone with more experience have any fuirther debugging tips or know how to fix?</p>