mirror of
https://github.com/tldr-pages/tldr.git
synced 2025-04-29 23:24:55 +02:00
mongo*: update pages & add mongosh (#10558)
This commit is contained in:
parent
2be0b2e18d
commit
cc5486d66e
3 changed files with 38 additions and 12 deletions
|
@ -1,20 +1,21 @@
|
||||||
# mongo
|
# mongo
|
||||||
|
|
||||||
> MongoDB interactive shell client.
|
> The legacy MongoDB shell. See `mongosh` for the new shell.
|
||||||
|
> Note: all connection options can be replaced with one string: `mongodb://user@host:port/db_name?authSource=authdb_name`.
|
||||||
> More information: <https://docs.mongodb.com/manual/reference/program/mongo>.
|
> More information: <https://docs.mongodb.com/manual/reference/program/mongo>.
|
||||||
|
|
||||||
|
- Connect to a local database on the default port (`mongodb://localhost:27017`):
|
||||||
|
|
||||||
|
`mongo`
|
||||||
|
|
||||||
- Connect to a database:
|
- Connect to a database:
|
||||||
|
|
||||||
`mongo {{database}}`
|
`mongo --host {{host}} --port {{port}} {{db_name}}`
|
||||||
|
|
||||||
- Connect to a database running on a given host on a given port:
|
- Authenticate using the specified username on the specified database (you will be prompted for a password):
|
||||||
|
|
||||||
`mongo --host {{host}} --port {{port}} {{database}}`
|
`mongo --host {{host}} --port {{port}} --username {{username}} --authenticationDatabase {{authdb_name}} {{db_name}}`
|
||||||
|
|
||||||
- Connect to a database with a given username; user will be prompted for password:
|
- Evaluate a JavaScript expression on a database:
|
||||||
|
|
||||||
`mongo --username {{username}} {{database}} --password`
|
`mongo --eval '{{JSON.stringify(db.foo.findOne())}}' {{db_name}}`
|
||||||
|
|
||||||
- Evaluate a JavaScript expression on the database:
|
|
||||||
|
|
||||||
`mongo --eval '{{JSON.stringify(db.foo.findOne())}}' {{database}}`
|
|
||||||
|
|
|
@ -3,14 +3,18 @@
|
||||||
> The MongoDB database server.
|
> The MongoDB database server.
|
||||||
> More information: <https://docs.mongodb.com/manual/reference/program/mongod>.
|
> More information: <https://docs.mongodb.com/manual/reference/program/mongod>.
|
||||||
|
|
||||||
|
- Specify the storage directory (default: `/data/db` on Linux and MacOS, `C:\data\db` on Windows):
|
||||||
|
|
||||||
|
`mongod --dbpath {{path/to/directory}}`
|
||||||
|
|
||||||
- Specify a config file:
|
- Specify a config file:
|
||||||
|
|
||||||
`mongod --config {{path/to/file}}`
|
`mongod --config {{path/to/file}}`
|
||||||
|
|
||||||
- Specify the port to listen on:
|
- Specify the port to listen on (default: 27017):
|
||||||
|
|
||||||
`mongod --port {{port}}`
|
`mongod --port {{port}}`
|
||||||
|
|
||||||
- Specify database profiling level. 0 is off, 1 is only slow operations, 2 is all:
|
- Specify the database profiling level. 0 is off, 1 is only slow operations, 2 is all (default: 0):
|
||||||
|
|
||||||
`mongod --profile {{0|1|2}}`
|
`mongod --profile {{0|1|2}}`
|
||||||
|
|
21
pages/common/mongosh.md
Normal file
21
pages/common/mongosh.md
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# mongosh
|
||||||
|
|
||||||
|
> A new shell for MongoDB, replacement for `mongo`.
|
||||||
|
> Note: all connection options can be replaced with one string: `mongodb://user@host:port/db_name?authSource=authdb_name`.
|
||||||
|
> More information: <https://www.mongodb.com/docs/mongodb-shell>.
|
||||||
|
|
||||||
|
- Connect to a local database on the default port (`mongodb://localhost:27017`):
|
||||||
|
|
||||||
|
`mongosh`
|
||||||
|
|
||||||
|
- Connect to a database:
|
||||||
|
|
||||||
|
`mongosh --host {{host}} --port {{port}} {{db_name}}`
|
||||||
|
|
||||||
|
- Authenticate using the specified username on the specified database (you will be prompted for a password):
|
||||||
|
|
||||||
|
`mongosh --host {{host}} --port {{port}} --username {{username}} --authenticationDatabase {{authdb_name}} {{db_name}}`
|
||||||
|
|
||||||
|
- Evaluate a JavaScript expression on a database:
|
||||||
|
|
||||||
|
`mongosh --eval '{{JSON.stringify(db.foo.findOne())}}' {{db_name}}`
|
Loading…
Add table
Reference in a new issue