title: Asterisk unable to connect to database using odbc connector
body: <p>I am pretty new to Asterisk and this is my first attempt to connect to database (MySQL). But I keep getting this error <strong>[unixODBC][Driver Manager]Data source name not found, and no default driver specified</strong>. Here is my setup:</p>
  
  <p>/etc/odbcinst.int</p>
  
  <pre><code>[Default]
  Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc.so
  
  [MySQL]
  Description = ODBC for MySQL
  Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc.so
  Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so
  FileUsage       = 1
  ;UsageCount = 2
  </code></pre>
  
  <p>/etc/odbc.ini</p>
  
  <pre><code>[MYSQL-DNS]
  Driver =MySQL
  Description = MySQL connection to ‘My Voice’ database
  Trace = Yes
  TraceFile = /tmp/odbc.log
  Server =localhost
  Port =3306
  Database =my_database
  UserName =myuser
  Password =mypass
  Option = 3
  Socket =/var/run/mysqld/mysqld.sock
  </code></pre>
  
  <p>/var/lib/asterisk/.profile </p>
  
  <pre><code>export ODBCINI=/etc/odbc.ini
  export ODBCSYSINI=/etc
  </code></pre>
  
  <p>I have also copied both odbcinst.ini and odbc.ini to ~/.odbcinst.ini and ~/.odbc.ini respectively and to /var/lib/asterisk/ just to clear all doubt.</p>
  
  <p>res_odbc.conf</p>
  
  <pre><code>[ENV]
  
  [my_database]
  enabled =&gt; yes
  dsn =&gt;MYSQL-DNS
  username =&gt; myuser
  password =&gt; mypass
  pre-connect =&gt; yes
  sanitysql =&gt; select 1
  ;idlecheck =&gt; 3600
  share_connections =&gt; yes
  pooling =&gt; no
  limit =&gt; 1
  ;isolation=repeatable_read
  </code></pre>
  
  <p>Command odbcinst -j outputs</p>
  
  <pre><code>$ odbcinst -j 
  unixODBC 2.3.2
  DRIVERS............: /etc/odbcinst.ini
  SYSTEM DATA SOURCES: /etc/odbc.ini
  FILE DATA SOURCES..: /etc/ODBCDataSources
  USER DATA SOURCES..: /etc/odbc.ini
  SQLULEN Size.......: 8
  SQLLEN Size........: 8
  SQLSETPOSIROW Size.: 8
  </code></pre>
  
  <p>I think I did a symbolic link to /usr/lib sometime back thus locate libmyodbc.so outputs</p>
  
  <pre><code>$ locate libmyodbc.so
  /usr/lib/libmyodbc.so
  /usr/lib/x86_64-linux-gnu/odbc/libmyodbc.so
  </code></pre>
  
  <p>I also added the x permission ie (changed from 644 to 755):</p>
  
  <pre><code>ls -alsh /usr/lib/x86_64-linux-gnu/odbc/
  </code></pre>
  
  <p>shows 755 for *.so</p>
  
  <p><strong>The Log Outputs</strong></p>
  
  <pre><code>res_odbc.c: Connecting my_database
  [Aug  1 09:32:40] WARNING[27846] res_odbc.c: res_odbc: Error SQLConnect=-1 errno=0 [unixODBC][Driver Manager]Data source name not found, and no default driver specified
  [Aug  1 09:32:40] WARNING[27846] res_odbc.c: Failed to connect to my_database
  [Aug  1 09:32:40] ERROR[27846] res_config_odbc.c: No database handle available with the name of 'my_database' (check res_odbc.conf)
  </code></pre>