The latest versions of the Asterisk PBX server connect to the Mysql database server by using ODBC. In this tutorial, I will show you how to set this up.
My test environment is CentOS Linux released on 7.9.2009, Asterisk 16.16.0, unixODBC 2.3.1, and Mysql Community Server 8.
I am taking for granted that you already have your Mysql installed and running. If you have not taken this step yet, you should use a tutorial like this one.
1 – Install the Unix ODBC:
# yum -y install unixODBC
2 – Download the official Mysql library connector from: https://dev.mysql.com/downloads/connector/odbc/
# wget https://cdn.mysql.com//Downloads/Connector-ODBC/8.0/mysql-connector-odbc-8.0.23-linux-glibc2.12-x86-64bit.tar.gz
Decompress the package in /usr/local directory or wherever you like.
# tar -zxvf mysql-connector-odbc-8.0.23-linux-glibc2.12-x86-64bit.tar.gz -C /usr/local
3 – Edit the file /etc/odbcinst.ini and insert the following code block:
[MySQL_ANSI] Driver=/usr/local/mysql-odbc/lib/libmyodbc8a.so sageCount=1
4 – Edit the file /etc/odbc.ini and create your connection:
[asterisk-connector]
Description = MySQL connection
Driver = MySQL_ANSI
Database = asterisk
Server = 127.0.0.1
Port = 3306
5 – Now, you must configure your Asterisk to use the connection. The file which contains that information is /etc/asterisk/res_odbc.conf
[asterisk] enabled => yes dsn => asterisk-connector username => user password => secret pre-connect => yes max_connections => 100
6 – Finally, make sure that Asterisk is using the ODBC module, take a look at the file /etc/asterisk/modules.conf and find the following line:
preload => res_odbc.so
If you have any questions, please use the comment box below.
2 replies on “Asterisk + ODBC + Mysql”
I need asterisk call recording Please? help us.
Payment is ready if you help how to record all the conversations in the asterisk and upload in to remote server as an backup archive.
Hi Ibrahim,
We can discuss it more in detail on a voice call.
I am looking forward to hearing from you.
Regards!