Backend Server Configuration
Overview
ProxySQL manages MySQL backend servers through the mysql_servers and
mysql_replication_hostgroups tables. All changes require loading to runtime to take effect and
saving to disk to persist across restarts.
Key Commands
LOAD MYSQL SERVERS TO RUNTIME;
SAVE MYSQL SERVERS TO DISK;
Adding Servers
INSERT INTO mysql_servers (hostgroup_id, hostname, port) VALUES (1, '10.0.0.1', 3306);
LOAD MYSQL SERVERS TO RUNTIME;
SAVE MYSQL SERVERS TO DISK;
Default values: port 3306, status ONLINE, weight 1, max connections 1000.
Configuration Options
| Column | Description |
|---|---|
hostgroup_id | Assigns server to a hostgroup |
hostname | Server address |
port | Server port (default 3306) |
status | ONLINE, OFFLINE_SOFT, or OFFLINE_HARD |
weight | Proportional traffic distribution within the hostgroup |
max_connections | Maximum connections ProxySQL will open to this server |
use_ssl | Enable SSL for backend connections (0 or 1) |
max_replication_lag | Automatically offline slaves exceeding this lag (seconds) |
compression | Enable compression for new connections (0 or 1) |
Hostgroup Assignment
The primary key (hostgroup_id, hostname, port) allows the same server to be a member of
multiple hostgroups for failover scenarios.
Server Status
| Status | Behaviour |
|---|---|
ONLINE | Active — receives traffic |
OFFLINE_SOFT | Graceful shutdown — existing connections continue, no new ones |
OFFLINE_HARD | Immediate — no new traffic; functionally equivalent to deleting the server |
Weight-Based Load Balancing
Weights distribute traffic proportionally within a hostgroup. A server with weight 3 receives
approximately three times the connections of a server with weight 1.
UPDATE mysql_servers SET weight=3 WHERE hostname='10.0.0.1';
LOAD MYSQL SERVERS TO RUNTIME;