Skip to main content

First Steps After Installing

Service Management

Once ProxySQL is installed, control the process with the service command or via the Admin interface.

Start

service proxysql start

Stop

service proxysql stop

Or via the Admin interface:

Admin> proxysql stop

Restart

service proxysql restart

Or via the Admin interface:

Admin> proxysql restart

Reinitialize from the Config File

After the first startup ProxySQL uses its SQLite database rather than the config file. To reset to the config file:

# init script
service proxysql initial

# systemd
systemctl start proxysql-initial

Checking the ProxySQL Version

proxysql --version
ProxySQL version v3.0.5, codename Truls

A debug build includes _DEBUG in the version string. It is slower but easier to troubleshoot:

ProxySQL version v3.0.5_DEBUG, codename Truls

The Admin Interface

The preferred way to configure ProxySQL is through its Admin interface — a MySQL-protocol SQL interface on port 6032. Configuration changes take effect without restarting the proxy.

Connecting

mysql -u admin -padmin -h 127.0.0.1 -P6032 --prompt='Admin> '
note

If your MySQL client is version 8.4 or later, add --default-auth=mysql_native_password.

Available Databases

Admin> SHOW DATABASES;
+-----+---------+-------------------------------+
| seq | name | file |
+-----+---------+-------------------------------+
| 0 | main | |
| 2 | disk | /var/lib/proxysql/proxysql.db |
| 3 | stats | |
| 4 | monitor | |
+-----+---------+-------------------------------+
  • main — active in-memory configuration (backend servers, users, query rules, variables)
  • disk — persisted configuration written to the SQLite database file
  • stats — runtime statistics (connections, query digest, memory usage)
  • monitor — health-check results for backend servers

After changing in-memory configuration, load it to runtime and optionally persist to disk:

LOAD MYSQL SERVERS TO RUNTIME;
SAVE MYSQL SERVERS TO DISK;

The Config File

The config file (/etc/proxysql.cnf) is a bootstrap mechanism — useful for the initial setup of a fresh instance. After the first start, the SQLite database takes precedence.

Top-Level Sections

admin_variables — controls the Admin interface:

admin_variables=
{
admin_credentials="admin:admin"
mysql_ifaces="127.0.0.1:6032"
}

mysql_variables — controls incoming MySQL traffic handling:

mysql_variables=
{
threads=4
max_connections=2048
interfaces="0.0.0.0:6033"
}

mysql_servers — backend server list:

mysql_servers=
(
{
address="127.0.0.1"
port=3306
hostgroup=0
max_connections=200
}
)

mysql_users — users allowed to connect through the proxy:

mysql_users=
(
{
username="root"
password="root"
default_hostgroup=0
max_connections=1000
default_schema="information_schema"
active=1
}
)

mysql_query_rules — traffic routing rules:

mysql_query_rules=
(
{
rule_id=1
active=1
match_pattern="^SELECT .* FOR UPDATE$"
destination_hostgroup=0
apply=1
},
{
rule_id=2
active=1
match_pattern="^SELECT"
destination_hostgroup=1
apply=1
}
)

datadir — path to the data directory:

datadir="/var/lib/proxysql"

Next Steps

Read How to Configure ProxySQL for the First Time for a complete step-by-step configuration walkthrough.