mysql Module

Table of Contents

1. Admin Guide
1.1. Overview
1.2. Dependencies
1.2.1. OpenSIPS Modules
1.2.2. External Libraries or Applications
1.3. Exported Parameters
1.3.1. exec_query_threshold (integer)
1.3.2. timeout_interval (integer)
1.3.3. max_db_queries (integer)
1.3.4. max_db_retries (integer)
1.3.5. tls_client_domain (string)
1.4. Exported Functions
1.5. Installation
1.6. Exported Events
2. Contributors
2.1. By Commit Statistics
2.2. By Commit Activity
3. Documentation
3.1. Contributors

List of Tables

2.1. Top contributors by DevScore(1), authored commits(2) and lines added/removed(3)
2.2. Most recently active contributors(1) to this module

List of Examples

1.1. Set exec_query_threshold parameter
1.2. Set timeout_interval parameter
1.3. Set max_db_queries parameter
1.4. Set max_db_retries parameter
1.5. Set the tls_client_domain parameter

Chapter 1. Admin Guide

1.1. Overview

This is a module which provides MySQL connectivity for OpenSIPS. It implements the DB API defined in OpenSIPS.

1.2. Dependencies

1.2.1. OpenSIPS Modules

The following modules must be loaded before this module:

  • If a tls_client_domain is defined, the tls_mgm module will need to be loaded as well.

1.2.2. External Libraries or Applications

The following libraries or applications must be installed before running OpenSIPS with this module loaded:

  • libmysqlclient-dev - the development libraries of mysql-client.

1.3. Exported Parameters

1.3.1. exec_query_threshold (integer)

If queries take longer than 'exec_query_threshold' microseconds, warning messages will be written to logging facility.

Default value is 0 - disabled.

Example 1.1. Set exec_query_threshold parameter

modparam("db_mysql", "exec_query_threshold", 60000)

1.3.2. timeout_interval (integer)

Time interval after which a 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 driver versions prior to 5.1.12, 5.0.25 and 4.1.22. The write timeout parameter is ignored on version 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).

Example 1.2. Set timeout_interval parameter

modparam("db_mysql", "timeout_interval", 2)

1.3.3. max_db_queries (integer)

The maximum number of database queries to be executed. If this parameter is set improperly, it is set to default value.

Default value is 2.

Example 1.3. Set max_db_queries parameter

modparam("db_mysql", "max_db_queries", 2)

1.3.4. max_db_retries (integer)

The maximum number of database connection retries. If this parameter is set improperly, it is set to default value.

Default value is 3.

Example 1.4. Set max_db_retries parameter

modparam("db_mysql", "max_db_retries", 2)

1.3.5. tls_client_domain (string)

Setting this parameter will enable TLS for all MySQL connections established by the module. Refer to the tls_mgm module for additional info regarding TLS client domains.

If using this parameter, you must also ensure that tls_mgm is loaded and properly configured.

Note that if you want to use this feature, the certificate must be provisioned in the configuration file, NOT in the database. In case you are loading TLS certificates from the database, you must at least define the default domain in the configuration script, where is currently the only place you can define it.

Default value is NULL (not set)

Example 1.5. Set the tls_client_domain parameter

modparam("tls_mgm", "client_domain", "1=")
modparam("tls_mgm", "certificate", "1:/etc/pki/tls/certs/opensips.pem")
modparam("tls_mgm", "private_key", "1:/etc/pki/tls/private/opensips.key")
modparam("tls_mgm", "ca_list",     "1:/etc/pki/tls/certs/ca.pem")
modparam("db_mysql", "tls_client_domain", "1=")

1.4. Exported Functions

No function exported to be used from configuration file.

1.5. Installation

Because it dependes on an external library, the mysql module is not compiled and installed by default. You can use one of the next options.

  • - edit the "Makefile" and remove "db_mysql" from "excluded_modules" list. Then follow the standard procedure to install OpenSIPS: "make all; make install".

  • - from command line use: 'make all include_modules="db_mysql"; make install include_modules="db_mysql"'.

1.6. Exported Events


This event is raised when a MySQL connection is lost or recovered.


  • url - the URL of the connection as specified by the db_url parameter.

  • status - connected if the connection recovered, or disconnected if the connection was lost.

Chapter 2. Contributors

2.1. By Commit Statistics

Table 2.1. Top contributors by DevScore(1), authored commits(2) and lines added/removed(3)

 NameDevScoreCommitsLines ++Lines --
1. Jan Janak (@janakj)1535353363190
2. Bogdan-Andrei Iancu (@bogdan-iancu)98701571791
3. Henning Westerholt (@henningw)59306931239
4. Daniel-Constantin Mierla (@miconda)2820571154
5. Liviu Chircu (@liviuchircu)2720391128
6. Andrei Pelinescu-Onciul16145249
7. Jiri Kuthan (@jiriatipteldotorg)1163932
8. Vlad Paiu (@vladpaiu)10812115
9. Razvan Crainea (@razvancrainea)10719430
10. Nils Ohlmeier53243

All remaining contributors: Norman Brandinger (@NormB), Vlad Patrascu (@rvlad-patrascu), Eseanu Marius Cristian (@eseanucristian), Dan Pascu (@danpascu), Ionut Ionita (@ionutrazvanionita), Ovidiu Sas (@ovidiusas), Konstantin Bokarius, Andreas Heise, Razvan Pistolea, Peter Lemenkov (@lemenkov), Saúl Ibarra Corretgé (@saghul), Sergio Gutierrez, Edson Gellert Schubert, Augusto Caringi.

(1) DevScore = author_commits + author_lines_added / (project_lines_added / project_commits) + author_lines_deleted / (project_lines_deleted / project_commits)

(2) including any documentation-related commits, excluding merge commits. Regarding imported patches/code, we do our best to count the work on behalf of the proper owner, as per the "fix_authors" and "mod_renames" arrays in opensips/doc/ If you identify any patches/commits which do not get properly attributed to you, please submit a pull request which extends "fix_authors" and/or "mod_renames".

(3) ignoring whitespace edits, renamed files and auto-generated files

2.2. By Commit Activity

Table 2.2. Most recently active contributors(1) to this module

 NameCommit Activity
1. Liviu Chircu (@liviuchircu)Mar 2014 - Jun 2018
2. Peter Lemenkov (@lemenkov)Nov 2017 - Nov 2017
3. Augusto CaringiJul 2017 - Jul 2017
4. Vlad Patrascu (@rvlad-patrascu)Apr 2017 - May 2017
5. Ovidiu Sas (@ovidiusas)Mar 2017 - Mar 2017
6. Razvan Crainea (@razvancrainea)Oct 2011 - Mar 2017
7. Ionut Ionita (@ionutrazvanionita)Feb 2016 - Feb 2016
8. Eseanu Marius Cristian (@eseanucristian)Jul 2015 - Jul 2015
9. Bogdan-Andrei Iancu (@bogdan-iancu)Aug 2002 - Oct 2014
10. Vlad Paiu (@vladpaiu)Feb 2011 - Aug 2014

All remaining contributors: Saúl Ibarra Corretgé (@saghul), Razvan Pistolea, Norman Brandinger (@NormB), Sergio Gutierrez, Henning Westerholt (@henningw), Daniel-Constantin Mierla (@miconda), Konstantin Bokarius, Edson Gellert Schubert, Andreas Heise, Jan Janak (@janakj), Andrei Pelinescu-Onciul, Dan Pascu (@danpascu), Jiri Kuthan (@jiriatipteldotorg), Nils Ohlmeier.

(1) including any documentation-related commits, excluding merge commits

Chapter 3. Documentation

3.1. Contributors

Last edited by: Liviu Chircu (@liviuchircu), Razvan Crainea (@razvancrainea), Eseanu Marius Cristian (@eseanucristian), Bogdan-Andrei Iancu (@bogdan-iancu), Vlad Paiu (@vladpaiu), Daniel-Constantin Mierla (@miconda), Konstantin Bokarius, Edson Gellert Schubert, Henning Westerholt (@henningw).

Documentation Copyrights:

Copyright © 2006 Voice Sistem SRL