ProxySQL MySQL MySQL · DBA · Configuration

ProxySQLConfig File Deep Dive

Complete reference for the proxysql.cnf configuration file. All sections explained — admin_variables, mysql_variables, servers, users, and query rules.

The /etc/proxysql.cnf file is the bootstrap configuration for ProxySQL. It is only read on the very first start (when no SQLite database exists). After that, all config is managed via the Admin interface and stored in proxysql.db.

Understanding the config file is important for initial setup and for scripted/automated deployments.

BASH — Full proxysql.cnf
datadir="/var/lib/proxysql"
errorlog="/var/lib/proxysql/proxysql_errorlog"

admin_variables=
{{
    admin_credentials="admin:admin"
    mysql_ifaces="0.0.0.0:6032"
    refresh_interval=2000
    web_enabled=false
    web_port=6080
    restapi_enabled=false
    restapi_port=6070
    cluster_username="proxycluster"
    cluster_password="clusterpass"
}}

mysql_variables=
{{
    threads=4
    max_connections=2048
    default_query_delay=0
    default_query_timeout=36000000
    have_compress=true
    poll_timeout=2000
    interfaces="0.0.0.0:6033"
    default_schema="information_schema"
    stacksize=1048576
    server_version="8.0.27"
    connect_timeout_server=3000
    monitor_username="monitor"
    monitor_password="monitor"
    monitor_history=600000
    monitor_connect_interval=60000
    monitor_ping_interval=10000
    monitor_read_only_interval=1500
    monitor_read_only_timeout=500
    ping_interval_server_msec=120000
    ping_timeout_server=500
    commands_stats=true
    sessions_sort=true
    connect_retries_on_failure=10
}}

mysql_replication_hostgroups=
(
    {{
        writer_hostgroup=10
        reader_hostgroup=20
        comment="MySQL Replication Setup"
    }}
)

mysql_servers=
(
    {{
        address="192.168.1.100"
        port=3306
        hostgroup=10
        status="ONLINE"
        weight=1
        compression=0
        max_connections=1000
        max_replication_lag=10
        use_ssl=0
        max_latency_ms=0
        comment="MySQL Master"
    }},
    {{
        address="192.168.1.101"
        port=3306
        hostgroup=20
        status="ONLINE"
        weight=1
        compression=0
        max_connections=1000
        max_replication_lag=10
        use_ssl=0
        max_latency_ms=0
        comment="MySQL Replica"
    }}
)

mysql_users=
(
    {{
        username="appuser"
        password="apppassword"
        default_hostgroup=10
        active=1
        transaction_persistent=1
        fast_forward=0
        backend=1
        frontend=1
        max_connections=10000
    }}
)

mysql_query_rules=
(
    {{
        rule_id=1
        active=1
        match_pattern="^SELECT .* FOR UPDATE"
        destination_hostgroup=10
        apply=1
        comment="Route SELECT FOR UPDATE to master"
    }},
    {{
        rule_id=2
        active=1
        match_pattern="^SELECT"
        destination_hostgroup=20
        apply=1
        comment="Route all SELECTs to replica"
    }}
)

scheduler=
(
)

mysql_firewall_whitelist_users=
(
)
VariablePurposeDefault
admin_credentialsAdmin username:passwordadmin:admin
mysql_ifacesAdmin interface bind address:port0.0.0.0:6032
refresh_intervalStats refresh interval in ms2000
web_enabledEnable web UIfalse
restapi_enabledEnable REST APIfalse
VariablePurposeDefault
threadsNumber of worker threads4
max_connectionsMax frontend connections2048
interfacesMySQL protocol bind address:port0.0.0.0:6033
server_versionVersion reported to clients5.5.30
monitor_usernameMySQL user for health checksmonitor
monitor_passwordPassword for monitor usermonitor
monitor_ping_intervalHow often to ping backends (ms)10000
monitor_read_only_intervalHow often to check read_only (ms)1500
connect_timeout_serverTimeout connecting to backend (ms)3000
default_query_timeoutMax query execution time (ms)36000000
💡 Note: After editing proxysql.cnf, the file is only re-read if you delete proxysql.db and restart. For running systems, always use the Admin interface.