proxysql.cnf — Overview
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.
Full Config File Structure
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=
(
)
Key Config Sections Explained
admin_variables
| Variable | Purpose | Default |
|---|---|---|
| admin_credentials | Admin username:password | admin:admin |
| mysql_ifaces | Admin interface bind address:port | 0.0.0.0:6032 |
| refresh_interval | Stats refresh interval in ms | 2000 |
| web_enabled | Enable web UI | false |
| restapi_enabled | Enable REST API | false |
mysql_variables
| Variable | Purpose | Default |
|---|---|---|
| threads | Number of worker threads | 4 |
| max_connections | Max frontend connections | 2048 |
| interfaces | MySQL protocol bind address:port | 0.0.0.0:6033 |
| server_version | Version reported to clients | 5.5.30 |
| monitor_username | MySQL user for health checks | monitor |
| monitor_password | Password for monitor user | monitor |
| monitor_ping_interval | How often to ping backends (ms) | 10000 |
| monitor_read_only_interval | How often to check read_only (ms) | 1500 |
| connect_timeout_server | Timeout connecting to backend (ms) | 3000 |
| default_query_timeout | Max 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.