mongodb连接参数

来源:互联网 发布:淘宝3c证书怎么上传 编辑:程序博客网 时间:2024/05/23 01:59

即mongo命令的参数

mongo test                      #连接到test库mongo 192.168.7.221/test<span style="white-space:pre"></span>#连接到指定IP的test库mongo 192.168.7.221:27018/test  #连接到指定IP,指定端口的test库

--eval

同mysql -e,不进入到mongo命令行执行--eval后面的语句

<pre name="code" class="sql"><pre name="code" class="sql">#mongo cric MongoDB shell version: 3.0.5connecting to: cricServer has startup warnings: 2015-08-24T11:17:53.412+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.2015-08-24T11:17:53.421+0800 I CONTROL  [initandlisten] > db.c1.count()3#mongo cric --eval "printjson(db.c1.count())"MongoDB shell version: 3.0.5connecting to: cric3

-u(--username)

指定用户

-p(--password)
指定密码

--quiet

屏蔽版本等信息

<pre name="code" class="sql"># mongoMongoDB shell version: 3.0.5connecting to: testServer has startup warnings: 2015-08-24T11:17:53.412+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.2015-08-24T11:17:53.421+0800 I CONTROL  [initandlisten] >#mongo --quiet> 


0 0
原创粉丝点击