MariaDB not connecting with Asterisk18

Hello, I’m fairly new to Asterisk and would really appreciate any help.

To get straight to the point, I’m having trouble connecting Asterisk 18 to MariaDB via ODBC. I don’t believe the issue is with the driver itself, as I can successfully connect to an external database. However, it seems like Asterisk isn’t even attempting to establish a connection. I hope that makes sense.

my /etc/odbcinst.ini files is the following
[MariaDB]
Driver=/usr/lib/x86_64-linux-gnu/odbc/libmaodbc.so
Description=MariaDB Connector/ODBC

my /etc/odbc.ini file has this configuration
[asterisk]
Description=MySQL Database
Driver=MariaDB
Server=serverAddressToOtherMachine
Database=sipdatabase
User=test_sip
Password = password123
Port = 3306

my res_odbc.conf is the following:
[AsteriskDB]
enabled => yes
dsn => asterisk
username => test_sip
password => password123
pre-connect => yes

When attempting to do isql -v asterisk im greeted with connected and I can successfully execute a query to the database.

Now, when I do odbc show on the asterisk CLI
I can see the name, DSN, and Last fail connecction attempt: followed by the timestamp.

I would much appreciate if anyone would help me out and we can sort out this issue please.

What flavor of Linux are you on? If you set in asterisk.conf set verbose and debug to 0. In /etc/asterisk/logger.conf put in full => notice,warning,error,debug,verbose,dtmf,fax and restart asterisk. Look /var/log/asterisk/full and grep for odbc and see if you see any errors.

If you do mysql -h serverAddressToOtherMachine -u test_sip -p'password123' sipdatabase and then show tables does it show anything?

Anderson_james Even I’m fairly new to asterisk and facing the same problem. mysql -h serverAddressToOtherMachine -u test_sip -p’password123’ works fine, odbc show on the asterisk CLI shows the correct dsn. But a sip show peers show nothing, and when attempted a connection, asterisk complains wrong password. Did you manage to get this working?

I have this working with both Debian 12 an Rocky Linux 8 and 9. I recall having a problem with /etc/odbcinst.ini (I don’t recall if it was Rocky or on Debian). This is what I have
for all three

# Driver from the mariadb-connector-odbc package
# Setup from the unixODBC package
[MariaDB]
Description     = ODBC for MariaDB
Driver          = /usr/lib/libmaodbc.so
Driver64        = /usr/lib64/libmaodbc.so
FileUsage       = 1

Also as a networking person I would do tcpdump -i any port 3306 -w /tmp/trace.pcap and see if you can look in the packets and see where the error/issue is.

Im using Ubuntu mysql -h serverAddressToOtherMachine -u test_sip -p’password123’ it successfully connects, and i can see the the schema for the database, its only when asterisk is trying to connect to it that is the problem, when entering odbc show into the cli i can see the following
Name:
DSN:
Last failed connection attempt: [timestamp]

How do you know asterisk is complaining about wrong password, for me it just says last failed connection attempt and its not letting me know why its failed.

I have changed packages from odbc-mariadb to mariadb-connector-odbc, I can run mysql -h ‘hostIP’ -u asterisk -p password123 and it connects successfully now, but when i run isql -v AsteriskDB it says /usr/lib/libmaodbc.so not found even though it is there, [01000][unixODBC][Driver manager] can’t open lib /usr/lib/libmaodbc.so file cannot be found.