OpenSRE uses MySQL diagnostics to investigate database issues — checking server health, surfacing slow queries, monitoring replication status, and analyzing table statistics. Queries are wrapped as read-only.
CREATE USER 'opensre_readonly'@'%' IDENTIFIED BY 'secure-password';GRANT PROCESS ON *.* TO 'opensre_readonly'@'%';GRANT REPLICATION CLIENT ON *.* TO 'opensre_readonly'@'%';GRANT SELECT ON performance_schema.* TO 'opensre_readonly'@'%';GRANT SELECT ON your_database.* TO 'opensre_readonly'@'%';FLUSH PRIVILEGES;
Three notes on these grants, each confirmed against a real server:
information_schema needs no explicit grant — MySQL exposes it automatically based on a
user’s other privileges. GRANT SELECT ON information_schema.* is rejected outright
(ERROR 1044) and aborts the script before later grants run.
The grant on the target database (MYSQL_DATABASE) is required — the connector
selects it as the default schema on connect, and without it every tool call fails with
Access denied ... to database.
REPLICATION CLIENT is required for get_mysql_replication_status (SHOW REPLICA STATUS
/ SHOW SLAVE STATUS) — without it, that one tool returns an access-denied error even
though integrations verify mysql and the other four tools pass.
performance_schema is enabled by default in MySQL 5.7+. Slow query data will not be available if it has been explicitly disabled in my.cnf.
Wait for it to become healthy, then create the read-only user and a table to inspect:
i=0until docker logs mysql-dev 2>&1 | grep -q "ready for connections.*port: 3306"; do i=$((i + 1)) [ "$i" -ge 30 ] && { echo "ERROR: MySQL never became ready" >&2; exit 1; } sleep 2done
docker exec mysql-dev mysql -uroot -prootpass -e "CREATE USER 'opensre_readonly'@'%' IDENTIFIED BY 'secure-password';GRANT PROCESS ON *.* TO 'opensre_readonly'@'%';GRANT REPLICATION CLIENT ON *.* TO 'opensre_readonly'@'%';GRANT SELECT ON performance_schema.* TO 'opensre_readonly'@'%';GRANT SELECT ON app_db.* TO 'opensre_readonly'@'%';FLUSH PRIVILEGES;CREATE TABLE app_db.orders (id INT PRIMARY KEY, amount DECIMAL(10,2));INSERT INTO app_db.orders VALUES (1, 42.50), (2, 17.00);"
SERVICE │ SOURCE │ STATUS │ DETAILmysql │ local env │ ✓ passed │ Connected to MySQL 8.0.46 │ │ │ target database: app_db.
Chat sessions only treat an integration as active once the store resolution has something to fall through to env vars with — an untouched ~/.opensre/integrations.json with an unrelated integration in it blocks env-var fallback entirely. Point OPENSRE_INTEGRATIONS_STORE_PATH at an empty, valid store instead, so your real config is never read or written and the exported MYSQL_* vars above are the only source of credentials:
A literal zero-byte file does not work here — the store loader expects valid JSON and raises on an empty read, so this writes an explicitly empty (but valid) store rather than just creating the file with mktemp alone.Kick off a long-running query so there is something real to investigate, then ask the agent:
docker exec -d mysql-dev mysql -uroot -prootpass -e "SELECT SLEEP(30);"opensre
Ask: Is anything blocking connections on the app_db MySQL instance?Against this exact local instance the agent calls all 5 registered tools — current
processes, server status, slow queries, table stats, and replication status — and
correctly identifies the synthetic SELECT SLEEP(30) probe as the only long-running
query, with every other health signal clean. An empty store makes the session fall
through to env-var resolution for every integration, not just MySQL — if your shell
already resolves another integration from its own env vars, it rides along too
(harmless).Teardown — remove the demo store file and unset every demo variable, so nothing lingers in the shell to affect a later command: