Documentation menu

Docs Connections: MySQL

Set up MySQL

Verbiqo needs one account that reads performance_schema and sys, and nothing that writes. MySQL 8.0 and later, Percona Server, Amazon RDS and Aurora are supported.

MySQL 5.7 is not supported. Verbiqo still connects, and every answer says first that the version is older than it supports and what it cannot read there: the slowest statements, when settings were changed, settings saved for the next restart, and Group Replication members. The rest of the answer is not a full review. Recommendations use SET PERSIST, which 5.7 lacks: run them as SET GLOBAL and add the setting to my.cnf.

At a glance

Supported tasksAsk about locks, slow statements, replication, Group Replication and InnoDB Cluster, settings, security and capacity, and explain a slow statement without running it. Questions: Ask MySQL. Every check: MySQL checks.
LimitationsVerbiqo reads performance_schema, sys and the server’s status, never your rows. Plans of your statements need SELECT on their tables (Level 5), which the monitoring account does not have by default. MariaDB is not supported yet.
Supported versionsMySQL 8.0 and later, Percona Server, Amazon RDS and Aurora. MySQL 5.7 is not supported: Verbiqo connects, but every answer says first what it cannot read there.
AuthenticationA password, a local socket with auth_socket (the server trusts the operating-system user), or a client certificate for an account with REQUIRE X509. A client key may have a passphrase. Secrets are kept in the Keychain or Windows Credential Manager.
Minimum permissionsPROCESS and REPLICATION CLIENT on *.*, SELECT on performance_schema.*, and SELECT, EXECUTE and SHOW VIEW on sys.*. REFERENCES on each application schema is recommended: without it, MySQL leaves that schema out of every list of databases, and its tables are not sized or checked. Commands: Create the monitoring account. What each level adds: Permission levels.
Connection testExtensions… › MySQL › Test Connection, or verbiqo mysql test <name>. A good test starts with Connected. and shows the product, version, role (source, replica or group member) and the TLS in use. On a version older than 8.0, it says so.
First useful questionThe orders app is hanging, what is going on? Verbiqo samples sessions, lock waits and transactions for 10 seconds. A schema change (DDL) queued behind an idle transaction is one finding, naming the session to end.
Safety controls
  • An account that can write or administer is refused when Verbiqo connects, including through a role. The RDS master user is refused.
  • The session is read-only, and each statement runs in START TRANSACTION READ ONLY.
  • 15 seconds per statement, and 2 seconds to wait for a lock.
  • Each statement is planned first. It is refused if it reads outside the monitoring schemas or would read too many rows.
  • EXPLAIN ANALYZE, SELECT … INTO and locking reads are refused. Verbiqo never reads mysql.user.
  • Every statement is on the access record.
Operational limitsThe model’s own reads return every row the server sends: the result reaches the model whole when it fits the model’s window, otherwise as exact totals computed from every row (the count; for numbers the minimum, maximum and sum; for text and times the minimum and maximum), with every row listed under the answer. Verbiqo’s own fixed checks read at most 500 rows, and so do the model’s reads when VERBIQO_MYSQL_SERVER_LOGS=0 turns the server logs off. The model may add up to 6 statements per question, after Verbiqo’s own checks. Your organization can set tighter limits: Limits you can add.

1. Create the monitoring account

As an administrator, on the source or primary. Replace 10.% with the addresses Verbiqo connects from, and shop with each application schema.

CREATE USER 'verbiqo_monitor'@'10.%' IDENTIFIED BY 'choose-a-password' WITH MAX_USER_CONNECTIONS 5;

-- Level 2, required: monitoring
GRANT PROCESS, REPLICATION CLIENT ON *.* TO 'verbiqo_monitor'@'10.%';
GRANT SELECT ON performance_schema.* TO 'verbiqo_monitor'@'10.%';
GRANT SELECT, EXECUTE, SHOW VIEW ON sys.* TO 'verbiqo_monitor'@'10.%';

-- Level 3, recommended: the schema in lists of databases, sizes, keys and indexes (no rows)
-- one line per application schema
GRANT REFERENCES ON shop.* TO 'verbiqo_monitor'@'10.%';

-- Level 4, InnoDB Cluster only
GRANT SELECT ON mysql_innodb_cluster_metadata.* TO 'verbiqo_monitor'@'10.%';

Why EXECUTE and SHOW VIEW on sys. Many sys views, such as sys.innodb_lock_waits and sys.statement_analysis, call sys’s own functions (sys.format_time(), sys.format_bytes()) and run with the reader’s rights. Without EXECUTE, reading them fails with error 1370. SHOW VIEW lets Verbiqo plan statements over those views. The sys routines only read and format monitoring data. Verbiqo accepts EXECUTE on sys.* only: an account with EXECUTE on any other schema, or on *.*, is refused, because routines there can change data.

To require TLS for the account, add REQUIRE SSL. For a certificate login, REQUIRE X509.

2. Add the connection

  1. Open the form

    Extensions… › MySQL.

  2. Fill it in

    Name, host, port (3306), user verbiqo_monitor, password. Schema is optional.

  3. Choose TLS

    With a CA-signed certificate, Verify identity and its CA. MySQL’s own certificate is self-signed: Required encrypts without checking it. Keep Preferred for a lab, because it falls back to no encryption when the server offers none.

  4. Test, then save

    The test shows the product, version, role (source, replica, group member) and TLS in use.

verbiqo mysql add orders-primary --host db1 --port 3306 --user verbiqo_monitor --password-stdin --ssl-mode REQUIRED
verbiqo mysql test orders-primary
Sign-inGive
Password on standard input--password-stdin (piped in. The form above)
Password in a variable--password-env VAR, for scripts and CI
Local socket--socket /var/run/mysqld/mysqld.sock instead of host and port, for an agent on the database’s own node. With no --user, Verbiqo signs in as the operating-system user, as auth_socket expects.
Client key with a passphrase--ssl-key-passphrase-env VAR or --ssl-key-passphrase-stdin (one value at a time arrives on stdin, so pair it with --password-env)

Every verb takes --json. One statement, under the same read-only rules as a question:

verbiqo mysql query orders-primary "SELECT * FROM performance_schema.replication_connection_status"

For a replica set or cluster, save a connection to each server. Verbiqo finds the others from whichever one you attach. Through MySQL Router, each connection may land on a different member: connect to members directly.

Query timeout. How long one statement may take, in seconds. The default is 15. Set it in the form (Limits, Query timeout) or with --query-timeout-seconds N; a blank field or default restores it. An organisation limit on query time still applies and wins when it is lower. When a statement hits it, the answer says so and names this setting.

verbiqo mysql add orders-primary --host db1 --user verbiqo_monitor --query-timeout-seconds 30

TLS and certificates

Your serverChoose
Default auto-generated certificateRequired, or Verify CA with the server’s ca.pem from its data directory.
Certificate from your CAVerify identity, with the CA certificate.
Account with REQUIRE X509Add the client certificate and key, and the key’s passphrase if it has one (the form’s passphrase field, --ssl-key-passphrase-env VAR or --ssl-key-passphrase-stdin. Kept in the Keychain or Credential Manager, never sent anywhere).

Verbiqo checks the host name itself in Verify identity, IP addresses included. Details: Encrypted connections.

Permission levels

Checked against MySQL 8.0 and 8.4 with an account holding exactly these grants.

LevelAddsVerbiqo can answer
1. Connect onlyNo grantsThe version and little elseNot enough
2. MonitoringPROCESS, REPLICATION CLIENT, performance_schema, sysSessions, locks and blockers, transactions, statements, indexes, replication, Group Replication, settings, security, what happenedRequired
3. Schema visibilityREFERENCES per schemaThe schema in lists of databases, table and index sizes, auto-increment limits, missing primary keys, index suggestions with real columnsRecommended
4. InnoDB ClusterSELECT on the cluster metadataMembers missing from the metadata, Router versionsClusters
5. Query plansSELECT on the application schemasPlans of statements you paste, including the search behind a slow UPDATE or DELETE. Verbiqo only plans them: every other statement stays limited to the monitoring schemas, so no row is readOptional, if your policy allows

Refused: any privilege that writes or administers (ALL, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, SUPER, RELOAD, FILE, GRANT OPTION, dynamic *_ADMIN privileges), including through a role. The RDS master user is refused. Create a separate account. Verbiqo never reads mysql.user.

Settings that help

Ask what should I enable? to see each item as ready or not.

ItemLets Verbiqo see
A monitoring account with PROCESS, REPLICATION CLIENT and reads on performance_schema and sysSessions, locks, replication, statements.
performance_schema onAlmost every diagnosis (on by default).
Statement history consumers onWhat each session ran recently.
Table metadata visible to the accountSizes, keys and indexes (Level 3).
InnoDB Cluster metadata readableThe cluster’s own view (Level 4).
Query plans: SELECT on the application schemasPlans of statements you paste, and slow writes (Level 5).
Slow query log (the mysql.slow_log table, or a file for Splunk)Past slow statements, grouped by statement: from the table, or from the file through Splunk.
Binary logs kept for point-in-time recoveryRecovery between backups. The events behind a replication error. The server keeps no record of the backups themselves.
Every deadlock written to the error logEach deadlock, not only the latest.
UPDATE performance_schema.setup_consumers SET ENABLED = 'YES'
 WHERE NAME IN ('statements_digest', 'events_statements_history');
SET PERSIST slow_query_log = ON;
SET PERSIST long_query_time = 1;
SET PERSIST log_output = 'FILE,TABLE';   -- keep TABLE: Verbiqo reads the slow log from mysql.slow_log; FILE is added for Splunk
SET PERSIST innodb_print_all_deadlocks = ON;
SET PERSIST binlog_expire_logs_seconds = 604800;   -- a week of binary logs; log_bin itself is set in my.cnf

Query plans, only if your policy allows the account to read the tables (Verbiqo still only plans):

GRANT SELECT ON `your_schema`.* TO 'verbiqo_monitor'@'%';

Put the consumer setting in my.cnf too, so it survives a restart. On RDS and Aurora, set these in the parameter group and turn performance_schema on there (reboot). Verbiqo recognises RDS, Aurora, Cloud SQL and Azure flexible server, and its settings advice says where to change each setting there.

Server logs

Verbiqo reads what the server logged about itself, so an answer about the past rests on what happened and not only on counters since the last restart. When a session opens, it asks the server which of these exist and which your account can read; what it cannot read is said, not skipped.

SourceWhat it holdsNeeds
performance_schema.error_logThe server’s error log, one row per event, with its timeMySQL 8.0.22 or later; nothing beyond the monitoring grants
performance_schema.events_errors_summary_*Error counts since the server started, by account, host, user, thread or errorNothing beyond the monitoring grants. Counters, not a period: an answer says since when they count
performance_schema.host_cacheConnection errors by client hostNothing beyond the monitoring grants. Empty when skip_name_resolve is ON
SHOW ENGINE INNODB STATUSThe latest deadlock, transactions, the redo logPROCESS, a monitoring grant. Record dumps and statement text are masked
mysql.slow_log and mysql.general_logSlow statements, or every statement, kept as tables when log_output includes TABLE. Past rows are read even if the log is off nowThe optional grant below. They have no index and are CSV files by default, so every read scans the whole table: Verbiqo states their size from information_schema without reading them, and the model narrows by time

Grants. Nothing beyond the documented monitoring grants, except this one, only if you want the slow log table read:

GRANT SELECT ON mysql.slow_log TO 'verbiqo_monitor'@'10.%';

Statement text in these logs (sql_text, argument) has its literal values masked before Verbiqo uses it.

Settings that matter.

SettingWhy
performance_schemaMust be ON; every source above except the InnoDB status is in it
log_outputInclude TABLE for the slow log table. Keep it when you also send the file to Splunk: FILE,TABLE
slow_query_log, long_query_timeThe slow log records only while it is ON, and only statements slower than long_query_time seconds
innodb_print_all_deadlocksON writes every deadlock to the error log, not only the latest to the InnoDB status

A question that names a period (“the last 24 hours”, “yesterday”, “since Monday”) is resolved to exact times on the server’s clock, and each answer says which reads cover that period and which are counters since the server started.

Logs in Splunk

  • Send both logs, the error log and the slow query log, each with its host. Any sourcetype name works.
  • One slow-log entry per Splunk event. Verbiqo names the sourcetype fix when entries are split.
  • Messages in English. What it finds: Log findings.

Next: Ask MySQL.

Common errors

The connection test and the answer say what went wrong. Find the message below, then follow the fix.

Message or symptomLikely causeWhat to doNeeds an administrator?
… can change or administer the server (…), so Verbiqo will not use it.The account holds a privilege that writes or administers, directly or through a role. The message names it.Create a separate monitoring account with only the read grants (step 1).Yes, to create the account.
The server refused the account or password.The user name or password is wrong, or the account does not match the address this computer connects from.Type the password again and press Test Connection. Check the host part of the account, such as '10.%'.Only if the account or password must change.
Nothing is listening on <host>:<port>. or <host> does not resolve.The host name or port is wrong, or the server is down.Check the host and port (3306 by default) in the connection.Only if the server is down.
… schema in use is not visible to this account, so not sized or checked, or list databases shows only information_schema, performance_schema, sys and the cluster metadata.The account holds no privilege on the application schema. MySQL lists only the schemas and tables an account holds a privilege on.Grant REFERENCES on each application schema (Level 3 in step 1), then ask again. It gives no access to rows.Yes, to grant it.
… accepted the connection and closed it during the handshake. If this is a MySQL Router port …The connection goes through MySQL Router, which has no member to send it to.Connect to a cluster member directly. Check the Router’s log and version.Yes, if the Router needs fixing.
The server accepts only encrypted connections: use TLS mode require or stricter.The account has REQUIRE SSL, or the server requires secure transport, and the connection does not use TLS.Choose TLS Required or stricter. More: Certificate and TLS errors.No.
MySQL 5.7… is older than Verbiqo supports (8.0 and later).The server runs MySQL 5.7. Verbiqo cannot read the slowest statements, setting history or Group Replication members there.Read the rest as a partial review. Run SET PERSIST advice as SET GLOBAL and add it to my.cnf. Upgrading to 8.0 gives full answers.Yes, to upgrade.
This account cannot plan statements over application tables.A plan needs SELECT on the statement’s tables, which the monitoring account lacks.If your policy allows, grant SELECT on that schema (Level 5). Verbiqo still only plans. It reads no rows.Yes.
performance_schema is off, so statement statistics, waits and lock details cannot be seen (it needs a restart to turn on).performance_schema, MySQL’s built-in record of activity, is turned off.Turn it on and restart. On RDS and Aurora, set it in the parameter group and reboot (Settings that help).Yes.

Something missing or unclear? Email hello@verbiqo.app.