Skip to content

MongoDB sessions

A MongoDB session opens a standalone server, a replica set or a sharded cluster (mongos). The tab shows databases and collections on the left and the documents of the selected collection on the right; the connection console under it logs the login and every command the browser sends, with its time, the number of documents or n/nModified, and the server’s error code and name.

Shared fields are on the Session dialog page: Databases tile → MongoDB. Default port 27017. Without Specify username the console asks login as (empty = no authentication):. Quick connect: mongodb://[email protected]:27017,db2.example.com/shop?replicaSet=rs0 or mongodb+srv://[email protected]/shop; user:password@ is refused.

Field Values Default What it does
Connection string mongodb://…, mongodb+srv://… Empty Fill in copies host, port, user, more hosts, database and the options replicaSet, authSource, authMechanism, tls/ssl, tlsCAFile, directConnection into the fields. A password in the string is not taken; other options are listed as not taken over. The string itself is not saved.
mongodb+srv On, off Off The driver looks up _mongodb._tcp.<host> (SRV) and <host> (TXT); the console prints the hosts found and the replicaSet/authSource from TXT. Turns TLS on.
More hosts host[:port], comma separated Empty Further seed hosts (replica set members).
Replica set Name Empty replicaSet: only members of this set are used. Empty: the driver finds the set from hello.
Direct connection On, off Off directConnection=true: only the remote host, no discovery and no failover.
Authentication SCRAM negotiated, SCRAM-SHA-256, SCRAM-SHA-1 Negotiated SASL mechanism; negotiated asks the server (saslSupportedMechs).
Auth database Database name Empty (admin) authSource.
TLS On, off Off See TLS certificate.
CA file PEM path Empty Certificates trusted besides the macOS trust settings (a private CA).
Database Name Empty Opened first in the tree; also listed when the user may not run listDatabases.
Allow write On, off Off The tab may switch Write mode on.
Production On, off Off Switching Write mode on asks for a confirmation.

The password is asked in the console and, after Save the password in the vault? [y/N], saved as password:mongodb://<user>@<host>:<port>. A rejected saved password stays in the vault until a new one is saved; a typed one is asked up to 3 times. With TLS off the console first asks TLS is off: log in with the password saved in the vault (…) over an unencrypted connection …? [y/N]: SCRAM does not send the password, but anyone who sees the exchange can try to guess it offline. After N the password is typed instead. SCRAM-SHA-1 without TLS gets a warning line.

The driver keeps the password inside its client, because every new pooled connection logs in with it. When the app locks, the tab closes that client (App locked: the MongoDB client of this tab was closed …), and commands are refused until the unlock. The next command after the unlock makes a new client and logs in again. The password is read from the vault again if the tab signed in with the saved one or saved the typed one, and only with TLS on. Otherwise type password in the console (the mongo> prompt). A password typed there is not saved, and from then on the tab does not read the vault.

In order: the address and options, the TLS trust, Using the password saved in the vault (…), Login <user>, authSource …, mechanism …, SRV/TXT lookup (with mongodb+srv), DNS and a TCP probe of up to 5 seed hosts (TCP connected to 192.0.2.31:27017 from … in 4 ms), per server the TCP connect and the TLS result, what the driver’s monitor sees per server (RsPrimary, set rs0, wire version 25, round trip 3 ms, or the error), ping ok, then hello (deployment and this member’s role), buildInfo (version, git hash) and connectionStatus (authenticated users and roles).

A replica set found without Replica set set, a direct connection to a secondary (writes fail) and mongos (stats summed over shards) each get a line saying so.

Each command afterwards: mongo> db <database>: <command as Extended JSON> and -> 50 documents in 7 ms, -> n=1, nModified=1 in 9 ms or -> server error 13 (Unauthorized): … (the user lacks the privilege …). Commands time out on the server after 60 s (maxTimeMS) and in the client after 90 s.

The driver reaches every server through a relay of the tab on 127.0.0.1 (random port, random SOCKS5 user and password), which does the TLS handshake with the macOS trust settings (Windows: the Windows certificate store) (plus the CA file) before anything else is sent. A certificate macOS does not trust (self-signed, expired, another host name, unknown CA) is read once more, shown (subject, SAN, issuer, validity, serial, SHA-256) and the console asks Trust this certificate for <host>:<port> (pin its SHA-256)? [y/N]. After y the fingerprint goes to mongo_known_hosts.json in the configuration folder and only that certificate is accepted for that host and port; the login is repeated. Each replica set member is asked about separately, also one found after the login.

A different certificate later prints CERTIFICATE CHANGED with both fingerprints and asks again, also when macOS trusts the new one: a saved pin is checked before the macOS trust. There is no option to switch verification off. The relay accepts TLS 1.2 and newer. A refused or declined server is not connected to again (not even TCP) until a review pins its certificate. A server address that is not TCP (a Unix socket in the replica set configuration) would bypass the relay: the console says so, the client is closed and commands are refused.

Text from the server and DNS (errors, hello, buildInfo, user and role names, SRV/TXT values) is printed with control characters shown as symbols.

Part Command Notes
Databases listDatabases Without the privilege: nameOnly + authorizedDatabases.
Collections listCollections Views and time series marked; without the privilege: authorizedCollections.
Documents find Filter, Projection, Sort as Extended JSON ({"$oid": …}, {"$date": …}, {"$numberLong": …}), page size 20–500, Previous/Next by skip. Count = count with the filter. Search: text in any top-level string field, as $regex (escaped, case-insensitive) over fields found in a $sample of 200 documents.
Document find by _id Eye icon: the whole document as canonical Extended JSON (types kept), up to 48 MiB of JSON. The list shortens strings over 4 KB, binaries over 256 bytes, arrays over 200 items and documents over 500 fields; a page stops at 32 MiB of BSON (the console says where; Next continues).
Aggregate aggregate Read-only: stages from a fixed list, also every stage of $lookup.pipeline, $unionWith.pipeline and each $facet pipeline (anything else there is refused); $out and $merge are refused.

Outside Write mode $where, $function and $accumulator (server-side JavaScript) are refused at any depth of the filter, projection and pipeline. | Indexes | listIndexes | | | Stats | $collStats storage stats | Documents, data and storage size, average document, indexes; summed over shards. Without the privilege: count. |

Command sent above the results shows the exact command document.

Off by default; the checkbox is shown only when the session has Allow write (read again when it is switched on; a session marked Production asks first). In Write mode: Insert, and on each document Update ($set and other operators), Replace (the whole document, prefilled as canonical Extended JSON) and Delete; in Aggregate, With $out / $merge…. Update, replace and delete act on one document (multi: false, limit: 1); the filter must contain the document’s _id. An empty replacement document is refused.

Show command builds the command in the app and shows it with its database as canonical Extended JSON ($numberLong, $date … exactly as sent); Send sends exactly that command (once, within 5 minutes). writeErrors and writeConcernError are shown as errors with code and name. Allow write turned off in the session, or Production turned on after Write mode was switched on, switches Write mode off at the next write, and nothing is sent.

KeePass export writes the MongoDB settings without Allow write; KeePass import leaves Allow write, Production and the CA file empty (set them in the session) and warns about a session without TLS.

Client certificates (tlsCertificateKeyFile), x.509, LDAP, Kerberos and AWS authentication, SSH tunnels, editing in a grid, export and import.

Scroll or pinch to zoom · drag to move · double-click to zoom · Esc or click outside to close