zoukankan      html  css  js  c++  java
  • MongoDB Shell (mongo)

    https://docs.mongodb.com/getting-started/shell/client/

    The mongo shell is an interactive JavaScript interface to MongoDB and is a component of the MongoDB package.

    You can use the mongo shell to query and update data as well as perform administrative operations.

    Start mongo

    Once you have installed and have started MongoDB, connect the mongo shell to your running MongoDB instance.

    Ensure that MongoDB is running before attempting to launch the mongo shell.

    On the same system where the MongoDB is running, open a terminal window (or a command prompt for Windows) and run the mongo shell with the following command:

    mongo

    On Windows systems, add .exe as follows:

    mongo.exe

    You may need to specify the path as appropriate.   //如果配置到环境变量的话,可以直接mongo

    When you run mongo without any arguments, the mongo shell will attempt to connect to the MongoDB instance running on the localhost interface on port 27017.

    To specify a different host or port number, as well as other options, see mongo Shell Reference Page.

    mongo --host localhost --port 27017

    mongo --host 192.168.1.18 --port 27017

    C:UsersAdministrator>mongo --host 192.168.1.63 --port 10001
    MongoDB shell version v3.4.2
    connecting to: mongodb://192.168.1.63:10001/
    MongoDB server version: 3.4.2
    Server has startup warnings:
    2017-03-02T17:36:14.784+0800 I CONTROL [initandlisten]
    2017-03-02T17:36:14.784+0800 I CONTROL [initandlisten] ** WARNING: Access contr
    ol is not enabled for the database.
    2017-03-02T17:36:14.785+0800 I CONTROL [initandlisten] ** Read and wri
    te access to data and configuration is unrestricted.
    2017-03-02T17:36:14.785+0800 I CONTROL [initandlisten]
    2017-03-02T17:36:14.785+0800 I CONTROL [initandlisten] Hotfix KB2731284 or late
    r update is not installed, will zero-out data files.
    2017-03-02T17:36:14.785+0800 I CONTROL [initandlisten]

    Help in mongo Shell

    Type help in the mongo shell for a list of available commands and their descriptions:

    help

    The mongo shell also provides <tab> key completion as well as keyboard shortcuts similar to those found in the bash shell or in Emacs.

    For example, you can use the <up-arrow> and the <down-arrow> to retrieve operations from its history.

    Additional Information

    See the following documents in the MongoDB Manual for more information on the mongo shell.

  • 相关阅读:
    【OI新闻】2016.10.06
    旧博客欢迎莅临
    【NYOJ42】一笔画问题
    LCIS最长公共上升子序列
    LIS最长上升子序列
    LCS最长公共子序列
    T2848 列车调度(二分或dp)
    二分图的最大匹配、完美匹配和匈牙利算法
    高精大水题
    最大0,1子矩阵
  • 原文地址:https://www.cnblogs.com/chucklu/p/6496309.html
Copyright © 2011-2022 走看看