← Data Console

Browse MongoDB, and check that read-only actually is

MongoDB has no schema to read, so the console samples documents to work out what each collection holds, then shows it as a table you can filter and follow. The more important thing on this page is the read-only user, because on MongoDB it is possible to create one that does nothing whatsoever.

Create a read-only MongoDB user

Verified — with one finding worth more than the command itself. On a mongod started WITHOUT access control, this user is created successfully and then enforces nothing: connecting as it, an insert and a drop both succeeded. Roles are only applied when the server runs with authorization enabled, so check that first.

// MongoDB 7, verified
use your_db
db.createUser({
  user: "dbshift_ro",
  pwd:  "a-strong-password",
  roles: [ { role: "read", db: "your_db" } ]
})

What browsing MongoDB looks like

  • The schema is inferred by sampling documents, so a collection with consistent shape reads like a table and an inconsistent one shows you exactly where it diverges.
  • Nested objects and arrays are shown as formatted JSON rather than as [object Object].
  • ObjectId values are shown as their 24-character hex form, and carry a creation time you can read.
  • Decimal128 is kept exact rather than rendered through a float.

What catches people out on MongoDB

A user with a read role on an unauthenticated server is not read-only

This is the one to check before anything else. Start mongod with --auth (or security.authorization: enabled) or the role you just created is decoration. Confirmed on MongoDB 7: without access control, a read-only user inserted and dropped without complaint.

A field missing from the sample is missing from the view

Inference works from a sample, so a field present in a small fraction of documents may not appear as a column. Rare fields are exactly the ones worth checking for by hand.

One field, two types

Nothing stops a field holding a string in some documents and a number in others. The console shows it widened, which is honest and a sign worth following up in the data.

A read-only login still shows everything

The user above stops writes. It does not stop someone reading every email address, card number and salary in the database, and it does not record who did. The console adds the other half: sensitive columns are detected and masked before the rows leave the server, unmasking is granted per column to named people, and every access is logged. Access Review answers "who can see what" across every source in one report, which is the question that is very hard to answer from a pile of grants.

Questions

How do I create a read-only user in MongoDB?

Use db.createUser with the built-in read role scoped to the database. Critically, the server must be running with access control enabled, or the role is never enforced — verified on MongoDB 7, where a read-only user on an unauthenticated server could still insert and drop.

Can the console browse MongoDB without a fixed schema?

Yes. It samples documents to infer the shape, shows nested objects and arrays as readable JSON, and tells you when a field's type is inconsistent rather than hiding it.

More on MongoDB

Other databases