%docentities; ]> &adminguide;
Overview This is a module which provides MySQL connectivity for Kamailio. It implements the DB API defined in Kamailio.
Dependencies
&kamailio; Modules The following modules must be loaded before this module: No dependencies on other &kamailio; modules.
External Libraries or Applications The following libraries or applications must be installed before running &kamailio; with this module loaded: mysql - the development libraries forthe Mysql database. In some Linux distributions named "libmysqlclient-dev".
Parameters
<varname>ping_interval</varname> (integer) Time interval in seconds to send ping messages to MySQL server in order to keep the connection open. Default value is 300 (5 min). Set <varname>ping_interval</varname> parameter ... modparam("db_mysql", "ping_interval", 600) ...
<varname>timeout_interval</varname> (integer) Time interval (in seconds) after that an connection attempt, read or write request is aborted. The value counts three times, as several retries are done from the driver before it gives up. The read timeout parameter is ignored on MySQL driver versions prior to 5.1.12, 5.0.25 and 4.1.22. The write timeout parameter is ignored on versions prior to 5.1.12 and 5.0.25, the 4.1 release don't support it at all. Default value is 2 (6 sec). Set <varname>timeout_interval</varname> parameter ... modparam("db_mysql", "timeout_interval", 2) ...
<varname>auto_reconnect</varname> (integer) Configure whether the module should automatically reconnect to MySQL server if the connection was lost. Default value is 1 (1 - on / 0 - off). Set <varname>auto_reconnect</varname> parameter ... modparam("db_mysql", "auto_reconnect", 0) ...
<varname>insert_delayed</varname> (integer) If set to 1, all INSERT SQL queries will be sent to MySQL server as INSERT DELAYED. Default value is 0 (1 - on / 0 - off). Set <varname>insert_delayed</varname> parameter ... modparam("db_mysql", "insert_delayed", 1) ...
<varname>update_affected_found</varname> (integer) If set to 1, all UPDATE SQL queries will return the number of matched rows instead of the number of "updated" rows. Default value is 0 (1 - on / 0 - off). Set <varname>update_affected_found</varname> parameter ... modparam("db_mysql", "update_affected_found", 1) ...
Functions No function exported to be used from configuration file.
Installation Because it dependes on an external library, the mysql module is not compiled and installed by default. You can use one of these options. - edit the "Makefile" and remove "db_mysql" from "excluded_modules" list. Then follow the standard procedure to install &kamailio;: "make all; make install". - from command line use: 'make all include_modules="db_mysql"; make install include_modules="db_mysql"'.
Reading configuration from my.cnf In order to take into account specific mysql client options, a my.cnf config group can be passed using the db_url module parameter. This is done by setting [group] in front of or instead of the host part. The following examples are valid db_url definitions, which include a my.cnf group: mysql://user:pass@[group]host:port/db mysql://user:pass@[group]:port/db mysql://user:pass@[group]/db mysql://[group]/db Set a my.cnf group in <varname>db_url</varname> parameter ... modparam("usrloc", "db_url", "mysql://[kamailio]/kamailio) ... Adding a kamailio group to my.cnf ... [kamailio] socket = /path/to/mysql.sock user = kamailiouser password = kamailiopass default-character-set = utf8 ... In addition to the given group, also the [client] section is read, in the order given in my.cnf. So if you for example specify a socket in both your specific group and the client group, then the value is taken from the last one. Using [client] and specific group ... [client] socket = /var/run/mysql/mysqld.sock [kamailio] socket = /path/to/mysqld.sock user = kamailiouser password = kamailiopass default-character-set = utf8 ... In the example given above, the socket /path/to/mysqld.sock is used by &kamailio; because both [kamailio] and [client] define this option, and the latter overwrites the first.