TheRobotLearns Platform · ProxySQL: from first install to production

Start ProxySQL and access the admin interface

  • about 15 min read

Learning objectives

  • Start ProxySQL with service commands and verify it with a version check.
  • Connect to ProxySQL admin via MySQL client over TCP loopback instead of socket localhost.
  • Identify ProxySQL's PostgreSQL admin connection alternative and port.
  • Apply ProxySQL generic-tarball security edits for admin credentials, listeners, interfaces, and ownership.
  • Explain ProxySQL admin databases by relating in-memory, SQLite, statistics, and monitor data.
  • Explain how ProxySQL config bootstraps fresh instances while SQLite takes precedence after start.
  • Run ProxySQL in Docker using sample config, mapped ports, and external admin credentials.
  • Map ProxySQL config sections for admin, query, backend, and datadir responsibilities.

Connect to admin over TCP loopback

localhost can send the MySQL client to a Unix socket instead of TCP. Use 127.0.0.1 for a TCP admin connection.

This command connects to the admin interface with the sample user and password over TCP on port 6032:

mysql -u admin -padmin -h 127.0.0.1 -P 6032 --prompt='ProxySQLAdmin> '

The command uses admin and the sample password. It uses 127.0.0.1 instead of localhost. The option -P 6032 selects the sample admin port. The prompt becomes ProxySQLAdmin> .

The Docker sample shows mysql_ifaces set to 0.0.0.0:6032 inside admin_variables. Its admin_credentials use admin:admin;radmin:radmin. The second pair is required to connect from outside the container.

If you use localhost, the MySQL client uses a Unix socket rather than a TCP connection.

Takeaway: Connect to ProxySQL Admin with mysql -u admin -padmin -h 127.0.0.1 -P 6032.

Harden the generic tarball first

A generic tarball leaves service setup to you. Unlike a distribution package, the tarball does not create the service account, install files into system paths, or register the service. The operator owns those steps and the upgrade or rollback procedure.

The archive contains bin/proxysql, etc/proxysql.cnf, systemd units, helper scripts, and runtime plugins when included by the release tier. The bundled systemd unit expects /usr/bin/proxysql, /etc/proxysql.cnf, a proxysql user and group, and a writable /var/lib/proxysql.

This command sequence creates the service account, installs files, reloads systemd, and enables the service:

sudo groupadd --system proxysql
sudo useradd --system --gid proxysql --home-dir /var/lib/proxysql --shell /usr/sbin/nologin proxysql
sudo install -d -o proxysql -g proxysql -m 0750 /var/lib/proxysql
sudo install -o root -g root -m 0755 bin/proxysql /usr/bin/proxysql
sudo install -o root -g proxysql -m 0640 etc/proxysql.cnf /etc/proxysql.cnf
sudo install -o root -g root -m 0644 systemd/system/proxysql.service systemd/system/proxysql-initial.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable proxysql

Before the first start, edit /etc/proxysql.cnf:

  • Replace the sample Admin credentials.
  • Restrict admin_variables.mysql_ifaces to trusted interfaces.
  • Review every other listener.
  • Install log rotation as appropriate.
  • Confirm file ownership.

Start only after those security settings are in place. Use proxysql-initial.service only when you intentionally want --initial behavior.

Takeaway: Edit the tarball's /etc/proxysql.cnf and ownership before the first systemctl start proxysql.

Map Docker ports and config

You want to try ProxySQL in Docker, but the container's listeners need host port mappings and credentials. The sample mounts a config file and maps three container ports to host ports.

This command maps container port 6032 to host port 16032, container port 6033 to host port 16033, and container port 6070 to host port 16070:

docker run -p 16032:6032 -p 16033:6033 -p 16070:6070 -d -v /path/to/proxysql.cnf:/etc/proxysql.cnf proxysql/proxysql

The sample config has three sections. datadir names the data directory. admin_variables holds admin_credentials and mysql_ifaces. mysql_variables holds MySQL-side settings, including threads, max_connections, interfaces, default_schema, server_version, monitor_username, monitor_password, connect_timeout_server, and ping_interval_server_msec.

The sample sets datadir to /var/lib/proxysql, threads to 4, max_connections to 2048, interfaces to 0.0.0.0:6033, and server_version to 5.5.30.

The sample admin_credentials use admin:admin;radmin:radmin. The second pair is required to connect from outside the container. The sample mysql_ifaces bind the admin listener to 0.0.0.0:6032.

For Kubernetes, sample Helm charts exist in the ProxySQL Kubernetes GitHub repository.

Takeaway: Map container ports to host ports, and use the second admin pair outside the container.

Open the admin prompt over TCP

mysql -u admin -padmin -h 127.0.0.1 -P 6032 --prompt='ProxySQLAdmin> '

The command connects to 127.0.0.1 on port 6032. It uses the sample admin user and password. It sets the prompt to ProxySQLAdmin>.

Try it: config_layer_sim

Start ProxySQL with sudo systemctl start proxysql, then verify it with proxysql --version. Connect to the admin interface with mysql -u admin -padmin -h 127.0.0.1 -P 6032 --prompt='ProxySQLAdmin> '. The prompt becomes ProxySQLAdmin> . For the Docker sample, run docker run -p 16032:6032 -p 16033:6033 -p 16070:6070 -d -v /path/to/proxysql.cnf:/etc/proxysql.cnf proxysql/proxysql. Connect from outside the container with the second sample pair, radmin:radmin.

Sources

Do more with an account

Start ProxySQL and access the admin interface — ProxySQL: from first install to production