Install the complete package with local command reference and every published mode.
install mongodbmongodbUse
mongodb [options] · mongodb : <json-command>mongodbshow the current
mongodb -c <host|uri> [user] [database] [-p <port>] [-n] [-m [name]]connect; password is requested separately when a user is supplied unless -n is used
-use <database>select another database
-llist databases
-tlist collections
-s <collection>show collection indexes
-n <collection> [documents]preview documents
-f <collection> <field> <value> [documents]find documents by one field
-o <collection> [file] [-f]export documents as JSON
-a <collection> : <json>insert one document
-w <collection> <field> <value> : <json>update matching documents
-d <collection> <field> <value>delete matching documents
-m [name]save the current connection in .lil.key; default name is the database
-M <name>remove a saved connection
-k [name]list saved connections or inspect one without showing its password
-K <name>connect using a saved connection
-edisconnect and clear connection data
mongodb : <json-command>execute a native database command document
mongodb dump [file.json] [-f]create an Extended JSON logical dump
mongodb load <file.json>restore a lil
Connect with mongodb:// or mongodb+srv:// without embedding credentials. Explore with -t, -n products 2 and -f products sku SHOE-1. To run a native command, pass a JSON object after :, for example
-w applies $set to every document matching the supplied field, and -d can remove every match. A collection export or dump contains documents, not index definitions or complete server configuration. lil uses Extended JSON for logical dumps where possible; it is not a replacement for server-side mongodump. Check permissions and backup before writes. Running the commands requires the
-l lists databases, -t lists collections, -s lists indexes, -n previews documents and -f matches one field/value pair. -o exports a collection as JSON.
-a inserts a JSON document. -w applies $set to documents matching one field/value pair. -d deletes documents matching one field/value pair. Complex operations remain available through native command documents after :.
dump stores collections as canonical Extended JSON strings when the driver supports them, preserving BSON types better than ordinary JSON. load restores lil
-c accepts either a host or a full
Commands run with the privileges of the supplied
When a full
Without -m, connection data remains scoped to the current PHP session. -m [name] explicitly stores the current profile in the protected .lil.key file (0600), -K <name> reconnects from it, -k lists or inspects profiles without exposing a stored password, and -M <name> removes one. kill removes .lil.key together with the other core state. Treat the file as sensitive because an opted-in profile can contain database credentials.
Run the prepared examples directly on the page. Their results are prebuilt and shown in the browser; no terminal command is executed on the server.
Install the current compatible version. Choose Base for the complete feature set or Minimum for the reduced package; use upgrade to update a module that is already installed.
Base and Minimum are two packages of the same current module release, not separate command versions.
Install the complete package with local command reference and every published mode.
install mongodbInstall the reduced package. Local reference is omitted;
install mongodb -mInstall exactly this published version.
install mongodb -v 1.1.4Ask upgrade to check compatibility and replace the installed block only when needed.
upgrade mongodbRemove the extension block while leaving the core and unrelated modules intact.
install mongodb -uExamples are copyable command lines, not actions executed by this website. Review paths, permissions and destructive flags before running them on a real project.
mongodbIllustrative sandbox preview — no live connection
A connection is required; the status view names the server and selected database.mongodb -c localhost -nIllustrative sandbox preview — no live connection
Connection example: server and database will be shown after a successful connection.mongodb -c mongodb://localhost/shop -nIllustrative sandbox preview — no live connection
Connection example: server and database will be shown after a successful connection.mongodb -c localhost demo shopIllustrative sandbox preview — no live connection
Password is requested separately; selected database: shop.mongodb -c localhost -p 27018 -nIllustrative sandbox preview — no live connection
Connection example: server and database will be shown after a successful connection.mongodb -use shopIllustrative sandbox preview — no live connection
Selected database: shop (requires an active connection)mongodb -lIllustrative sandbox preview — no live connection
admin
shopmongodb -tIllustrative sandbox preview — no live connection
productsmongodb -s productsIllustrative sandbox preview — no live connection
_id_ {"_id":1} (example of a standard index)mongodb -n products 2Illustrative sandbox preview — no live connection
{"sku": "SHOE-1", "name": "City shoe", "category": "shoes", "price": 79.9, "active": true}
{"sku": "BAG-1", "name": "Canvas bag", "category": "bags", "price": 44.5, "active": true}mongodb -f products sku SHOE-1 2Illustrative sandbox preview — no live connection
{"sku": "SHOE-1", "name": "City shoe", "category": "shoes", "price": 79.9, "active": true}mongodb -o productsIllustrative sandbox preview — no live connection
[
{
"sku": "SHOE-1",
"name": "City shoe",
"category": "shoes",
"price": 79.9,
"active": true
},
{
"sku": "BAG-1",
"name": "Canvas bag",
"category": "bags",
"price": 44.5,
"active": true
}
]mongodb -o products tmp/products-mongo.jsonIllustrative sandbox preview — no live connection
Saved sandbox/tmp/products-mongo.json (if the destination does not exist)mongodb -o products tmp/products-mongo.json -fIllustrative sandbox preview — no live connection
Saved sandbox/tmp/products-mongo.json (replace existing file only with -f)mongodb -a products : {"sku":"NEW-1","name":"Sample","price":5}Illustrative sandbox preview — no live connection
Inserted 1
ID generated by servermongodb -w products sku BAG-1 : {"price":40}Illustrative sandbox preview — no live connection
Matched 1
Updated 1 (example only)mongodb -d products sku BAG-1Illustrative sandbox preview — no live connection
Deleted 1 (example only; all matches would be affected)mongodb : {"count":"products"}Illustrative sandbox preview — no live connection
{"n":2,"ok":1} (server response can include additional fields)mongodb dump tmp/shop-mongo.jsonIllustrative sandbox preview — no live connection
Saved sandbox/tmp/shop-mongo.json
Format lil-mongodb-json (logical data export, not server backup)mongodb dump tmp/shop-mongo.json -fIllustrative sandbox preview — no live connection
Saved sandbox/tmp/shop-mongo.json
Format lil-mongodb-json (logical data export, not server backup)mongodb load db/mongodb.jsonIllustrative sandbox preview — no live connection
Restores documents from the bundled lil-mongodb-json sample; duplicate or existing records may conflict.mongodb -m shop-demoIllustrative sandbox preview — no live connection
Saved shop-demo (stores a sensitive profile in .lil.key)mongodb -kIllustrative sandbox preview — no live connection
No saved connections (unless a profile has already been saved)mongodb -k shop-demoIllustrative sandbox preview — no live connection
Saved connection not found: shop-demo (unless saved earlier)mongodb -K unknownIllustrative sandbox preview — no live connection
Saved connection not found: unknownmongodb -M unknownIllustrative sandbox preview — no live connection
Saved connection not found: unknownmongodb -eIllustrative sandbox preview — no live connection
+mongodb -c localhost -p 99999 -nIllustrative sandbox preview — no live connection
Invalid database portmongodb -c mongodb://user:password@localhost/shop -nIllustrative sandbox preview — no live connection
Credentials must be entered separatelysandbox/db/mongodb.jsonThe example uses a file or directory from the protected /sandbox/ documentation workspace.
{
"format": "lil-mongodb-json",
"version": 1,
"database": "shop",
"created": "2026-08-09T00:00:00+00:00",
"collections": {
"products": [
"{\"sku\":\"SHOE-1\",\"name\":\"City shoe\",\"category\":\"shoes\",\"price\":79.9,\"active\":true}",
"{\"sku\":\"BAG-1\",\"name\":\"Canvas bag\",\"category\":\"bags\",\"price\":44.5,\"active\":true}"
]
}
}
Current stable release of