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:\Users\Administrator>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.

 

转载于:https://www.cnblogs.com/chucklu/p/6496309.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值