Skip to main content

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

ColumnDescription
hostgroup_idAssigns server to a hostgroup
hostnameServer address
portServer port (default 3306)
statusONLINE, OFFLINE_SOFT, or OFFLINE_HARD
weightProportional traffic distribution within the hostgroup
max_connectionsMaximum connections ProxySQL will open to this server
use_sslEnable SSL for backend connections (0 or 1)
max_replication_lagAutomatically offline slaves exceeding this lag (seconds)
compressionEnable 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

StatusBehaviour
ONLINEActive — receives traffic
OFFLINE_SOFTGraceful shutdown — existing connections continue, no new ones
OFFLINE_HARDImmediate — 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;