TheRobotLearns Platform · ProxySQL: from first install to production
Navigating ProxySQL Admin Schemas
Learning objectives
- Name the five main Admin schemas and say where runtime_* tables belong.
- Explain main as in-memory config with runtime_* tables and disk as runtime_*-free mirror.
- Use default admin/stats users correctly, noting admin connects locally only regardless of password.
- Predict MySQL/PostgreSQL Admin behavior and SQLite3 SHOW DATABASES translation caveats.
- Separate debug-only myhgm and monitor_internal schemas from normal Admin schemas.
Five Admin schemas at a glance
You run SHOW DATABASES in the Admin interface, ProxySQL's configuration CLI, and see main, disk, stats, monitor, and stats_history. The MySQL and PostgreSQL outputs list the same five names. ProxySQL converts SHOW DATABASES into the equivalent SQLite3 command.
main is the in-memory configuration database, and it also holds runtime_* tables populated with the current runtime configuration ProxySQL is using. disk is the disk-based mirror of main without the runtime_* tables. Across restarts, main is not persisted; ProxySQL loads it from disk or from a config file based on startup flags and whether an on-disk database exists.
stats contains runtime metrics from the proxy, including query-rule match counts and currently running queries. monitor contains backend-server metrics, including minimum and maximum times to connect or ping. stats_history contains historical metrics used by longer-running requirements such as the Web UI and Firewall. Debug-only myhgm and monitor_internal are for development and testing, and they are enabled only in debug builds.
Takeaway: main and disk carry configuration; stats, monitor, and stats_history carry metrics.
Choose admin and stats users
You connect with the default admin credentials to change tables. The default admin user can only connect locally, regardless of its password. The admin user has read-write access to all tables, while the stats user has read-only access to statistics tables.
The stats user is used for metrics pulling without exposing too much of the database. The default credentials are admin/admin and stats/stats. Both user types are configurable through admin-admin_credentials and admin-stats_credentials. Access still happens through the MySQL or PostgreSQL Admin interface, and ProxySQL sends suitable queries to embedded SQLite3.
main is the in-memory configuration database, and SQL lets you query and update configuration there. With commands such as LOAD MYSQL USERS FROM MEMORY, contents from main.mysql_users propagate into the in-memory runtime structures. The runtime_* tables in main show the runtime configuration ProxySQL is using, while disk does not hold those tables.
Takeaway: Use local admin for read-write changes, and stats for read-only statistics.
Why USE changes nothing
You run USE main in the Admin interface. The command is accepted, but it does not change the default schema. That happens because ProxySQL sends suitable queries to the embedded SQLite3 engine, and SQLite3 does not offer that USE behavior.
The Admin interface can speak MySQL or PostgreSQL, yet command support follows the SQLite3 query path. ProxySQL converts SHOW DATABASES into an equivalent SQLite3 command. The MySQL and PostgreSQL outputs both list main, disk, stats, monitor, and stats_history. In that output, disk and stats_history show paths, while the other listed databases show empty file fields.
This asks for the schema list, then tries to select main:
SHOW DATABASES;
USE main;The first SHOW DATABASES returns the five names. The USE line is accepted, but it does not switch the default schema.
SQL syntax used by SQLite3 differs from MySQL and PostgreSQL, so not all commands work on SQLite3.
Takeaway: SHOW DATABASES lists five schemas; USE main does not change the default schema.
Inspect Admin schemas and USE main
-- Ask Admin which schemas are visible.
SHOW DATABASES;
-- Try to make main the default schema.
USE main;SHOW DATABASES returns main, disk, stats, monitor, and stats_history, because ProxySQL converts that command into the SQLite3 equivalent. USE main is accepted by the Admin interface, but it does not change the default schema.
Try it: config_layer_sim
Connect to the ProxySQL Admin interface as the default local admin user. Run SHOW DATABASES; the output lists main, disk, stats, monitor, and stats_history. Run USE main; the Admin interface accepts it, but the default schema does not change.
Sources
Do more with an account
- Graded quizzes is available on your account.
- Saving your progress is available on your account.
- Hands-on labs is available on your account.
- AI tutoring is available on your account.