MYSQL module
Admin Guide
Section titled “Admin Guide”Overview
Section titled “Overview”This is a module which provides MySQL connectivity for OpenSIPS. It implements the DB API defined in OpenSIPS.
Dependencies
Section titled “Dependencies”OpenSIPS Modules
Section titled “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.
External Libraries or Applications
Section titled “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.
Exported Parameters
Section titled “Exported Parameters”exec_query_threshold (integer)
Section titled “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.
...modparam("db_mysql", "exec_query_threshold", 60000)...timeout_interval (integer)
Section titled “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).
...modparam("db_mysql", "timeout_interval", 2)...max_db_queries (integer)
Section titled “max_db_queries (integer)”The maximum number of retries to execute a failed query due to connections problems. If this parameter is set improperly, it is set to default value.
Default value is 2.
...modparam("db_mysql", "max_db_queries", 2)...max_db_retries (integer)
Section titled “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.
...modparam("db_mysql", "max_db_retries", 2)...tls_client_domain (string)
Section titled “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)
...modparam("tls_mgm", "client_domain", "1=10.11.12.13:3306")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=10.11.12.13:3306")...Exported Functions
Section titled “Exported Functions”No function exported to be used from configuration file.
Installation
Section titled “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”’.
Exported Events
Section titled “Exported Events”E_MYSQL_CONNECTION
Section titled “E_MYSQL_CONNECTION”This event is raised when a MySQL connection is lost or recovered.
Parameters:
- 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.
doc copyrights:
Contributors
Section titled “Contributors”By Commit Statistics
Section titled “By Commit Statistics”Top contributors by DevScore(1), authored commits(2) and lines added/removed(3)
| # | Name | DevScore | Commits | Lines++ | Lines— |
|---|---|---|---|---|---|
| 1. | Jan Janak (@janakj) | 154 | 53 | 5406 | 3260 |
| 2. | Henning Westerholt (@henningw) | 108 | 32 | 2630 | 3176 |
| 3. | Bogdan-Andrei Iancu (@bogdan-iancu) | 102 | 71 | 1705 | 925 |
| 4. | Liviu Chircu (@liviuchircu) | 32 | 23 | 492 | 228 |
| 5. | Daniel-Constantin Mierla (@miconda) | 28 | 20 | 574 | 157 |
| 6. | Razvan Crainea (@razvancrainea) | 17 | 14 | 220 | 48 |
| 7. | Andrei Pelinescu-Onciul | 16 | 14 | 54 | 51 |
| 8. | Vlad Paiu (@vladpaiu) | 12 | 9 | 160 | 49 |
| 9. | Jiri Kuthan (@jiriatipteldotorg) | 11 | 6 | 393 | 2 |
| 10. | Stefan Darius (@dariusstefan) | 7 | 4 | 223 | 30 |
All remaining contributors: Vlad Patrascu (@rvlad-patrascu), Nils Ohlmeier, Norman Brandinger (@NormB), Eseanu Marius Cristian (@eseanucristian), Dan Pascu (@danpascu), Ionut Ionita (@ionutrazvanionita), Ovidiu Sas (@ovidiusas), Andreas Heise, Razvan Pistolea, Konstantin Bokarius, 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
(3) ignoring whitespace edits, renamed files and auto-generated files
By Commit Activity
Section titled “By Commit Activity”| # | Name | Commit Activity |
|---|---|---|
| 1. | Stefan Darius (@dariusstefan) | Jun 2026 - Jul 2026 |
| 2. | Razvan Crainea (@razvancrainea) | Oct 2011 - Jun 2026 |
| 3. | Liviu Chircu (@liviuchircu) | Mar 2014 - Dec 2020 |
| 4. | Vlad Patrascu (@rvlad-patrascu) | Apr 2017 - Jul 2020 |
| 5. | Vlad Paiu (@vladpaiu) | Feb 2011 - Dec 2019 |
| 6. | Bogdan-Andrei Iancu (@bogdan-iancu) | Aug 2002 - Jun 2018 |
| 7. | Peter Lemenkov (@lemenkov) | Nov 2017 - Nov 2017 |
| 8. | Augusto Caringi | Jul 2017 - Jul 2017 |
| 9. | Ovidiu Sas (@ovidiusas) | Mar 2017 - Mar 2017 |
| 10. | Ionut Ionita (@ionutrazvanionita) | Feb 2016 - Feb 2016 |
All remaining contributors: Eseanu Marius Cristian (@eseanucristian), 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
Documentation
Section titled “Documentation”Contributors
Section titled “Contributors”Last edited by: Razvan Crainea (@razvancrainea), Liviu Chircu (@liviuchircu), Bogdan-Andrei Iancu (@bogdan-iancu), Eseanu Marius Cristian (@eseanucristian), Vlad Paiu (@vladpaiu), Daniel-Constantin Mierla (@miconda), Konstantin Bokarius, Edson Gellert Schubert, Henning Westerholt (@henningw), Jan Janak (@janakj).
License
Section titled “License”All documentation files (i.e. .md extension) are licensed under the Creative Common License 4.0