参考:链接
1. Start the mongo
Shell and Connect to MongoDB
mongo "mongodb://alice:Admin!2#@mongodb0.examples.com:28015/?authSource=admin"
mongo --username alice --password --authenticationDatabase admin --host mongodb0.examples.com --port 28015
2. Connect to a MongoDB Replica Set
mongo "mongodb://mongodb0.example.com.local:27017,mongodb1.example.com.local:27017,mongodb2.example.com.local:27017/?replicaSet=replA"
mongo --host replA/mongodb0.example.com.local:27017,mongodb1.example.com.local:27017,mongodb2.example.com.local:27017
If using the DNS Seedlist Connection Format, you can specify the connection string:
mongo "mongodb+srv://server.example.com/"
Use of the +srv
connection string modifier automatically sets the ssl option to true for the connection.
3. TLS/SSL Connection
mongo "mongodb://mongodb0.example.com.local:27017,mongodb1.example.com.local:27017,mongodb2.example.com.local:27017/?replicaSet=replA&ssl=true"
mongo --ssl --host replA/mongodb0.example.com.local:27017,mongodb1.example.com.local:27017,mongodb2.example.com.local:27017
Working with the mongo
Shell
db
use <database>
use myNewDatabase
db.myCollection.insertOne( { x: 1 } );
db.getCollection("3 test").find()
db.getCollection("3-test").find()
db.getCollection("stats").find()
Format Printed Results
db.myCollection.find().pretty()
.mongorc.js
File
When starting, mongo
checks the user’s HOME
directory for a JavaScript file named .mongorc.js
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于