# Unixodbc, asterisk and mysql

**URL:** <https://community.asterisk.org/t/unixodbc-asterisk-and-mysql/8917>\
**Category:** Asterisk Support\
**Created:** [August 31, 2006, 11:53am UTC](https://community.asterisk.org/t/unixodbc-asterisk-and-mysql/8917 "2006-08-31T11:53:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![newbie\_aste](https://avatars.discourse-cdn.com/v4/letter/n/2acd7d/32.png) [@newbie\_aste](https://community.asterisk.org/u/newbie_aste)\
**Post date:** [August 31, 2006, 11:53am UTC](https://community.asterisk.org/t/unixodbc-asterisk-and-mysql/8917/1 "2006-08-31T11:53:39Z")

</div>

I having problems configuring the asterisk realtime. I don’t know If I have setup my odbc correctly. I having errors when I execute “isql -v” The error as it follows.  
"[IM010][unixODBC][Driver Manager]Data source name too long  
[ISQL]ERROR: Could not SQLConnect"

When trying to login in asterisk CLI, I executed a command “odbc show” and resulted into errors again.  
"odbc show  
Name: asterisk  
DSN: asterisk  
Connected: no

Sep 30 19:03:06 WARNING[11648]: res\_odbc.c:238 odbc\_sanity\_check: Connection is down attempting to reconnect…  
Sep 30 19:03:06 WARNING[11648]: res\_odbc.c:499 odbc\_obj\_disconnect: res\_odbc: asterisk [asterisk] already disconnected  
Sep 30 19:03:06 NOTICE[11648]: res\_odbc.c:554 odbc\_obj\_connect: Connecting asterisk  
Sep 30 19:03:06 WARNING[11648]: res\_odbc.c:565 odbc\_obj\_connect: res\_odbc: Error SQLConnect=-1 errno=0 [unixODBC][Driver Manager]Data source name not found, and no default driver specified"

Below are the configs the I have.

;  
; odbc.ini  
;

[myodbc3]  
Driver = /usr/local/lib/libmyodbc3.so  
Description = MyODBC 3.51 Driver DSN  
SERVER = localhost  
PORT =  
USER = astiadm  
Password = imx1015  
Database = voip\_db  
OPTION = 3  
SOCKET =

odbcinst.ini  
[MySQL]

[MySQL ODBC Driver]  
DRIVER = /usr/local/lib/libmyodbc3.so  
SETUP = /usr/local/lib/libmyodbc3S.so  
UsageCount = 1

How will I check If I have a successfully installtion of unixodbc?I did not use any gui during the installtion of unixodbc. Please advise. I’m really a newbie on this one.

Best regards,  
newbie\_aste

---

<div class="post-metadata">

**Author:** ![dmikusa](https://avatars.discourse-cdn.com/v4/letter/d/e47c2d/32.png) [@dmikusa](https://community.asterisk.org/u/dmikusa)\
**Post date:** [August 31, 2006, 2:00pm UTC](https://community.asterisk.org/t/unixodbc-asterisk-and-mysql/8917/2 "2006-08-31T14:00:50Z")

</div>

It seems that your ODBC connection is not working. If you cannot connect with isql, then there is no way Asterisk will be able to connect. Make sure that you can use isql to connect to your database before you proceed.

Here’s my setup I’m using Ubuntu. This is my driver ini file.

[MySQL]  
Description = MySQL ODBC MyODBC Driver  
Driver = /usr/lib/odbc/libmyodbc.so  
Setup = /usr/lib/libodbcmyS.so

Make sure the driver and setup options are to the location of those files on your system. This is my DSN ini file

[asterisk]  
Description = MySQL ODBC For Asterisk  
Trace = Yes  
TraceFile = /tmp/odbc.log  
Driver = MySQL  
Server = ip\_addr  
User = dbuser  
Password = secret  
Port = 3306  
Database = name

You need to install the driver first, use this command

sudo odbcinst -i -d -f driver.ini

Then install the DSN, use this command

sudo odbcinst -i -s -l -f dsn.ini

This will install a system DSN, which is in my opinion the easiest way to do things.

The test using isql.

isql asterisk dbuser secret

Dan
