ODBC not connecting to mysql

Hi There,

i am new to this community. Happy to be around. As a newbie, i’ll be much more asking than replying for a time. But i hope to be of help shortly.

I have been a couple of days trying to connect asterisk 16 to mysql, but odbc keeps refusing to connect.

within the asterisk cli, this is what we get from ‘odbc show all’
ODBC DSN Settings

Name: astcdr
DSN: astcdr
Last fail connection attempt: 2020-04-28 09:29:24
Number of active connections: 0 (out of 1)
Logging: Disabled

Then i tried to reload module res_odbc for this output:
[Apr 28 09:29:24] WARNING[3507]: res_odbc.c:1067 odbc_obj_connect: res_odbc: Error SQLConnect=-1 errno=2002 [unixODBC][MySQL][ODBC 5.2(w) Driver]Can’t connect to local MySQL server through socket '/var/lib/m

These are the contents of:

Description = MySQL connection to database
Driver = MySQL
Database = cdr
Server = localhost
User = root
Password = mypassword
Port = 3306
Socket = /var/lib/mysqld/mysqld.sock

Description = ODBC for MySQL
Driver = /usr/lib/libmyodbc5.so
Setup = /usr/lib/libodbcmyS.so
Driver64 = /usr/lib64/libmyodbc5.so
Setup64 = /usr/lib64/libodbcmyS.so
FileUsage = 1


Any help is welcome.

Many thanks.

You’ve configured a socket to connect to the MySQL database, is that the correct location? If you remove the socket and use TCP/IP on localhost does it work?

I have finally found the little b****d

Socket definition was wrong. It was /var/lib/mysql/mysql.sock instead of ‘mysqld’

Now Asterisk is connecting to Mysql. Now i have to find out why is it not dumping anything to the DB. But thats a different issue.

Many thanks for your help.

1 Like