mongo
The legacy MongoDB shell. See
mongoshfor 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://www.mongodb.com/docs/mongodb-shell/.
- Connect to a local database on the default port (
mongodb://localhost:27017):
mongo
- Connect to a database:
mongo --host --port
- Authenticate using the specified username on the specified database (you will be prompted for a password):
mongo --host --port --username --authenticationDatabase
- Evaluate a JavaScript expression on a database:
mongo --eval ''
来源:tldr-pages contributors · 作者与贡献记录 · CC BY 4.0。离线整理了版式、链接和媒体显示。
