User Rating: 5 / 5

Star Active Star Active Star Active Star Active Star Active
 
MariaDB_Logo.png

So many of you may be already aware that from FreeSWITCH 1.10.x it is possible to connect directly to MariaDB (and MySQL) without using ODBC. I am trying right now with a customer's server, and so far it is working very nice. So, I will describe how to make it work.

Load mod_mariadb

Edit your /etc/freeswitch/autoload_configs/pre_load_modules.conf.xml and put a content as follows:

<configuration name="pre_load_modules.conf" description="Modules">  
       <modules>  
               <!-- Databases -->  
               <load module="mod_mariadb"/>
       </modules>  
</configuration>

Don't forget to make sure you have compiled mod_mariadb.

Generate your MariaDB DSN String

This is the tricky part, it took me a while to figure it out. MariaDB DSN strings are not as standard as PostgreSQL. The syntax is:

dsn=mariadb://Server=IP;Database=DATABASENAME;Uid=USERNAME;Pwd=PASSWORD

Save your DSN

The best place to put this string is in the vars.xml file. Like this:

<X-PRE-PROCESS cmd="set" data="dsn=mariadb://Server=IP;Database=DATABASENAME;Uid=USERNAME;Pwd=PASSWORD" />

From this point, you can use it in any FreeSWITCH module, you just refer to it as $${dsn}, double $ sign is important to tell FreeSWITCH not to try to resolve the string each time it finds it. Think of it as if it was a constant.

Notes about using MySQL

Please note that the module is called mod_mariadb, not mod_mysql. It is thought to work with MariaDB. In some cases, you will need to do some database changes if you still want to use MySQL with it.

Good Luck!

blog comments powered by Disqus

About

Read about IT, Migration, Business, Money, Marketing and other subjects.

Some subjects: FusionPBX, FreeSWITCH, Linux, Security, Canada, Cryptocurrency, Trading.