Mongodb - Difference between running “mongo” and “mongod” databases

后端 未结 3 1323
悲&欢浪女
悲&欢浪女 2020-12-12 12:39

So, I\'m sure I\'m missing something simple here, but when I run mongo as a daemon (using mongod --fork or just mongod), I see different database content than if I just run

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-12 13:11

    MongoD(Daemon process). In simple "Hello world" words - You won't communicate Mongod directly. Instead, you use DB client:

    • Mongo Shell (run mongo) - In an interactive JavaScript interface (-or- run mongosh the new MongoDB Shell).
    • Compass - Graphical view of MongoDB (Or studio 3t and other GUI apps).
    • Drivers (Like node -or- JAVA drivers).

    And you find more tools like this.

    In your case, you want to use Mongo Shell client (mongo command).

    Visual

    A great way to see "the client" - "in action" is to open two terminals (or more) side by side.

    Run mongod (mongo command will not work without MongoDB server install and running), then run mongo:

    Output (1 connection: application mongo shell}

    Next, run some CRUD Operations and see the messages under mongod.

    Same idea if you connect Compass client:

    Manage mongodb processes docs (Change data directory, Port and so on): https://docs.mongodb.com/manual/tutorial/manage-mongodb-processes/

提交回复
热议问题