欢迎投稿

今日深度:

shell操作mongodb,shellmongodb

shell操作mongodb,shellmongodb


想通过shell查询MongoDB的数据

网上好多人说,mongoDB不支持shell,这个说法我是基本赞同的大笑

但是项目需要,我不得不尝试着做,关键要使用--eval

如我要查询用户数量:

#cat count_users.sh

#!/bin/sh

/usr/bin/mongo  xxx --quiet --authenticationDatabase admin -u root -p 'xyz' --eval "db.system.users.count()"

注意:

1.quiet只输出结果

2.eval这是evaluate javascript

3.--authenticationDatabase admin 执行auth验证,这个不能忘记啊!大笑

authenticationDatabase可以参看我这篇文章:http://blog.csdn.net/jacson_bai/article/details/41013259


www.htsjk.Com true http://www.htsjk.com/shujukunews/6285.html NewsArticle shell操作mongodb,shellmongodb 想通过shell查询MongoDB的数据 网上好多人说,mongoDB不支持shell,这个说法我是基本赞同的 ; 但是项目需要,我不得不尝试着做, 关键要使用--eval 如我要查询用...
评论暂时关闭