Skip to content

Configuration file

Jesmar Cannaò edited this page Nov 27, 2018 · 5 revisions

ProxySQL config file is parsed using libconfig , and its grammar is described here

For reference, grammar it is also copied at the end of this document.
For examples, refers to sample config file.

Please refer to Startup for a description of when the config file is parsed.

General variables

Configuration file has 4 variables that are always parsed even if a database file is present:

  • datadir : it defines the path of ProxySQL datadir, where database file, logs and other files are stored
  • restart_on_missing_heartbeats (new in 1.4.4) : if MySQL threads miss restart_on_missing_heartbeats heartbeats, proxysql will raise a SIGABRT signal and restart. Default is 10 . See watchdog .
  • execute_on_exit_failure (new in 1.4.4) : if set, ProxySQL parent process will execute the defined script every time ProxySQL crashes. It is recommended to use this setting to generate an alert or log the event. Note that proxysql is able to restart in few milliseconds in case of crash, therefore it is possible that a normal failure is not detected by other monitoring tools.
  • errorlog (new in 2.0.0) : if set, ProxySQL will use the defined file as error-log. In case such variable is not passed, the errolog will be located in datadir/proxysql.log

Modules variables

Specific modules requires their variables to be configured in a section called module_variables. For example admin_variables for variables related to admin module, and mysql_variables for variables related to mysql module.

Within each section where the variables are configured, the variable prefix (mysql- , admin-, or others) must not be specified. Admin module automatically adds the prefix relative to the section when loading the variables into the global_variables table. For example:

  • admin- prefix will be added to all variables defined in admin_variables
  • mysql- prefix will be added to all variables defined in mysql_variables

Here is an example of how variables are defined in config file (prefix must not be specified):

mysql_variables=
{
    threads=4
    max_connections=2048
    default_query_delay=0
    default_query_timeout=36000000
    have_compress=true
}

When loaded into global_variables table, they will have the mysql- prefix. Example:

Admin> SELECT * FROM global_variables WHERE variable_name IN ('mysql-threads','mysql-max_connections', 'mysql-default_query_delay','mysql-default_query_timeout','mysql-have_compress');
+-----------------------------+----------------+
| variable_name               | variable_value |
+-----------------------------+----------------+
| mysql-default_query_delay   | 0              |
| mysql-default_query_timeout | 36000000       |
| mysql-have_compress         | true           |
| mysql-max_connections       | 2048           |
| mysql-threads               | 4              |
+-----------------------------+----------------+
5 rows in set (0,00 sec)

libconfig grammar

Below is the BNF grammar for configuration files. Comments and include directives are not part of the grammar, so they are not included here.

configuration = setting-list | empty

setting-list = setting | setting-list setting

setting = name (":" | "=") value (";" | "," | empty)

value = scalar-value | array | list | group

value-list = value | value-list "," value

scalar-value = boolean | integer | integer64 | hex | hex64 | float
               | string

scalar-value-list = scalar-value | scalar-value-list "," scalar-value

array = "[" (scalar-value-list | empty) "]"

list = "(" (value-list | empty) ")"

group = "{" (setting-list | empty) "}"

empty =



Terminals are defined below as regular expressions:

boolean		([Tt][Rr][Uu][Ee])|([Ff][Aa][Ll][Ss][Ee])
string		\"([^\"\\]|\\.)*\"
name		[A-Za-z\*][-A-Za-z0-9_\*]*
integer		[-+]?[0-9]+
integer64	[-+]?[0-9]+L(L)?
hex		0[Xx][0-9A-Fa-f]+
hex64		0[Xx][0-9A-Fa-f]+L(L)?
float		([-+]?([0-9]*)?\.[0-9]*([eE][-+]?[0-9]+)?)|([-+]([0-9]+)(\.[0-9]*)?[eE][-+]?[0-9]+)
Clone this wiki locally