Find sensitive data in database tables. The agent reads the first rows of each table with a read-only login.
What it scans
| Content | Read? | How to change it |
|---|---|---|
| The first rows of every table (a table sample) | Yes: 1,000 rows by default | Rows read per table (sample_rows, 1–10,000) |
| Column names | Yes | Always on |
| Views, materialized views, sequences, functions | Never | Not configurable |
System schemas (pg_catalog, information_schema, pg_toast*; MySQL mysql, sys, performance_schema, information_schema) |
Never | Not configurable |
- Each table becomes one CSV pseudo-file: a header row of column names, then the sampled rows. It is classified like any CSV file, with the same rules and engines.
- Every cell is cut at 2,000 characters inside the database, so a huge text value never crosses the network.
- Only labels, counts and names (database, schema, table, columns) reach the console. Row values never leave the agent, the same as for files.
- "Where to look" shows the database, schema and table, the columns whose values matched a rule, and the full column list.
Why a sample, not the whole table? Sensitive columns show up in the first rows almost every time, and reading a 50-million-row table every day would load the database and the agent for little extra signal. Raise Rows read per table if your tables are sparse.
What you need
- An agent that can reach the database host and port.
- PostgreSQL 12 or newer, MySQL 8.0 or newer, or MariaDB 10.6 or newer.
- A dedicated read-only login (Step 1). The agent also makes every session read-only itself, but a read-only role is the real guarantee.
The hosted agent does not scan databases; use an agent on your own network.
Step 1: Create a read-only login
Run as a superuser or the database owner. pg_read_all_data (PostgreSQL 14+) grants SELECT on every table:
CREATE ROLE myrikeep_scan LOGIN PASSWORD '<PASSWORD>';
GRANT CONNECT ON DATABASE app TO myrikeep_scan;
GRANT pg_read_all_data TO myrikeep_scan;
Before PostgreSQL 14, or to limit the scan to some schemas, grant per schema instead:
GRANT USAGE ON SCHEMA public TO myrikeep_scan;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO myrikeep_scan;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO myrikeep_scan;
CREATE USER 'myrikeep_scan'@'%' IDENTIFIED BY '<PASSWORD>';
GRANT SELECT ON app.* TO 'myrikeep_scan'@'%';
Replace % with the agent's address to accept the login only from the agent host.
Tables the login cannot read are listed as skipped items with a reason; the scan goes on.
PostgreSQL row-level security: pg_read_all_data does not bypass row-level security (RLS). A table
whose policies apply to the scan login is never reported as clean. If a policy calls a function the login
may not execute, the table is skipped with a row_level_security reason. If the policy lets the login
through, only the rows it allows are read — and the table is still reported as not fully read. To scan
RLS-protected tables, grant the login BYPASSRLS: ALTER ROLE myrikeep_scan BYPASSRLS;
Step 2: Add your connection
- Open Connections → Add connection and pick PostgreSQL database or MySQL / MariaDB database.
- Enter the host, the database name and, if it is not the default, the port.
- Keep the default encryption mode (verified) and, if your server's certificate comes from your own CA, paste that CA's certificate into CA certificate (see below).
- Select your agent, choose Local credential catalog and enter a credential name such as
APP_DB.
Put the username in the secret file, not in the console config.
Encryption and your own CA
By default the agent checks the server's certificate and its host name: PostgreSQL verify-full, MySQL
verify. Why: without that check, any machine on the network path can pretend to be your database,
receive the scan login's password and read the sampled rows. Encryption alone does not stop that; only
verification does.
| Mode | PostgreSQL | MySQL / MariaDB | Server verified? |
|---|---|---|---|
| Default | verify-full |
verify |
Yes: certificate and host name |
| CA only | verify-ca |
— | Certificate yes, host name no |
| Encrypted only | require, prefer |
encrypted (old name on) |
No |
| Unencrypted | allow, disable |
off |
No |
- Certificates from a public CA verify against the agent's system trust store with nothing to configure.
- Your own CA (homelabs, internal PKI, MySQL's auto-generated certificates): paste the CA's public
certificate, the
-----BEGIN CERTIFICATE-----block, into CA certificate (tls_ca_pem). Several certificates (a chain) are fine, up to 16 KB. The console refuses anything else, and it always refuses a private key. The agent keeps the CA in memory (MySQL) or in a 0600 temp file that exists only while it connects (PostgreSQL). - The server certificate must name the host you entered (subjectAltName DNS or IP). MySQL's auto-generated
certificate does not: issue a server certificate from your CA, or choose
encryptedknowingly. - The agent uses strict X.509 checks: your CA certificate needs
keyUsagewithkeyCertSign(OpenSSL:-addext "keyUsage=critical,keyCertSign,cRLSign"). - The modes marked No are explicit opt-ins for networks you trust. The form labels them "not verified", and the agent logs one warning per scan while one is in use.
To get a server's CA certificate, ask whoever runs the server, or for MySQL's own CA copy ca.pem from its
data directory (for example docker cp <mysql-container>:/var/lib/mysql/ca.pem .).
Step 3: Prepare credentials and scan
- Save the JSON and catalog from Secret file on the agent, using the read-only mount in Agent credentials.
- Wait for present.
- Queue a scan from Scans.
You should see the scan complete, then results in Coverage and Findings.
Connection settings table
| Console field | Example | Required or optional |
|---|---|---|
| Connection name | Billing database |
Required; unique in workspace |
| Type | PostgreSQL (postgres) or MySQL / MariaDB (mysql) |
Required |
| Host | db.internal |
Required; hostname or IP, no URL |
| Port | 5432 |
Optional; default 5432 (PostgreSQL) or 3306 (MySQL) |
| Database name | app |
Required |
Encryption (tls) |
verify-full; MySQL verify |
Optional; default verify-full (PostgreSQL), verify (MySQL); see Encryption |
CA certificate (tls_ca_pem) |
-----BEGIN CERTIFICATE-----… |
Optional; your CA's public certificate, up to 16 KB, never a key |
Only these schemas (include_schemas) |
public |
Optional, PostgreSQL only; one per line |
Skip these schemas (exclude_schemas) |
audit |
Optional, PostgreSQL only; one per line |
Rows read per table (sample_rows) |
1000 |
Optional; 1–10,000, default 1,000 |
Maximum tables per scan (max_tables) |
500 |
Optional; 1–5,000, default 500 |
| Agent | Office agent |
Required; same workspace |
| Credential mode | Local credential catalog | Required |
| Credential name | APP_DB |
Required; uppercase alias |
| Exclude patterns (View/edit) | audit/* |
Optional; one glob per line |
Secret file
Save /srv/myrikeep/secrets/APP_DB. Both values must be nonempty strings:
{"username": "myrikeep_scan", "password": "<PASSWORD>"}
Merge this catalog entry (use "type": "mysql" for MySQL):
{"version": 1, "credentials": {"APP_DB": {"type": "postgres", "source": {"kind": "file_json", "path": "/run/secrets/APP_DB"}}}}
Follow Agent credentials for file modes and the directory mount. The console never receives the password.
Scope, exclusions and schedules
- Only these schemas and Skip these schemas choose PostgreSQL schemas by exact name. System schemas are always skipped.
- Tables are scanned in name order, up to Maximum tables per scan. The rest are counted as
database_tables_not_scannedon the scan. - Exclude globs match these pseudo-paths (names are percent-encoded):
| Pseudo-path | Database | Table locator |
|---|---|---|
public/customers.csv |
PostgreSQL | postgres://db.internal:5432/app/public/customers |
customers.csv |
MySQL | mysql://db.internal:3306/app/customers |
| Glob | Effect |
|---|---|
audit/* |
Skips every table in the PostgreSQL schema audit |
*_log.csv |
Skips tables whose names end in _log |
See Getting started for schedules. Databases follow the same once-a-day default as every source.
How the agent protects your database
- Every session is read-only: PostgreSQL runs
SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLYanddefault_transaction_read_only = on; MySQL runsSET SESSION TRANSACTION READ ONLY. The agent reads the setting back and refuses to scan if it did not take effect. - Every query has a 60-second server-side timeout (PostgreSQL
statement_timeout, MySQLmax_execution_time, MariaDBmax_statement_time). PostgreSQL also sets a shortlock_timeout, so a scan never queues behind a long migration. - Table and column names are always quoted as identifiers, so a table named with quotes or semicolons cannot change the query.
- Rows stream from a server-side cursor (PostgreSQL) or an unbuffered cursor (MySQL); one table sample is held in memory at a time, capped at 64 MiB.
"Who can see it" support
Sharing checks are not available for this source yet. Database grants are not assessed.
See Who can see it.
Troubleshooting
| Symptom or state | Fix |
|---|---|
unknown |
Check heartbeat, assignment and current connection revision. |
unsupported_source |
Upgrade the agent; older agents do not scan databases. |
missing / credential_missing |
Match catalog alias and type (postgres or mysql) and check the secret mount. |
Invalid / credential_config_invalid |
Use exactly username/password strings. |
PostgreSQL connection failed (OperationalError) |
Check host, port, pg_hba.conf for the agent's address, and the encryption mode. |
Connection failed right after adding it (PostgreSQL OperationalError, MySQL OperationalError_2003) with a self-signed or private-CA server |
Verification failed: paste the CA certificate into CA certificate, and check that the server certificate names the host you entered. |
MySQL connection failed (a class ending in _1045) |
Wrong username or password, or the user's host part does not match the agent. |
Skipped table: InsufficientPrivilege (PostgreSQL) or OperationalError_1142 (MySQL) |
Grant SELECT on the table (Step 1). |
Skipped table: QueryCanceled (PostgreSQL) or a class ending in _3024 (MySQL) |
The query hit the 60-second timeout; the table is busy or very slow. |
| Session did not become read-only | A pooler or proxy rejected the session settings; connect the agent to the database directly. |
Limits
| Limit | Value |
|---|---|
| Rows per table | sample_rows, at most 10,000 |
| Characters per cell | 2,000 |
| Table sample size | 64 MiB |
| Tables per scan | max_tables, at most 5,000 |
| Query timeout | 60 seconds |
Never done: writing, locking for write, creating objects, reading views or system schemas.
Skipped, with a reason: tables the login cannot read and tables whose query times out.