Set up a read-only user.
The common scenario: a stakeholder wants to see live data, an on-call engineer needs to investigate without risking a bad UPDATE, or your auditor needs query access. Don't share your admin password — make them a read-only user.
What "read-only" means in Ledger
Read-only is enforced at two layers:
- MySQL grants — the underlying database user can only run SELECT, SHOW, EXPLAIN. Even if Ledger were bypassed entirely, the database itself wouldn't accept writes.
- Ledger application — even within those grants, Ledger's read-only mode rejects write statements before they're sent. This catches multi-statement edge cases and gives clearer error messages.
Step by step
-
Create the MySQL user. Log into Ledger as admin, open the SQL editor, paste:
CREATE USER 'ledger_readonly'@'localhost' IDENTIFIED BY 'pick-a-strong-password'; GRANT SELECT, SHOW VIEW, PROCESS ON *.* TO 'ledger_readonly'@'localhost'; FLUSH PRIVILEGES;The
PROCESSgrant lets them see (but not kill) processes. Drop it if you don't want that. -
Add the Ledger user. Open the admin panel — typically at
/admin/usersin your install — and click "Add user". Username can match the MySQL one, password is separate. -
Enable read-only mode for this user. In the user form, check the Read-only toggle. This is the application-layer guard.
-
Set the connection. In Ledger's database connection setting (per-user or global, depending on your install), use the
ledger_readonlyMySQL credentials for this user's session. Don't reuse the admin MySQL user. -
Test it. Log out, log back in as the new user. Try running an UPDATE. You should see "Read-only mode enabled — write statements are blocked" before the query even reaches MySQL.
*.* in the GRANT with your_db.*. Granting on *.* includes the mysql system database — usually not what you want.