首页 > 其他 > 详细

mongo 常用命令

时间:2020-04-17 09:19:58      阅读:55      评论:0      收藏:0      [点我收藏+]

一、连接mongo

mongo 127.0.0.1:27016 -u "mongotest" -p --authenticationDatabase "testDB"

二、基本操作

1、show dbs; #查看所有库
2、use test1; #选中某库和mysql use一样
3、show collections; #查看所有的表
4、db.getCollection(‘test_table‘).find({"city": "成都"}); #查询
5、db.getCollection("test_table").find({"rent_type": "整租"}, {"lng": 1,"lat": 1}); #查询
6、db.getCollection("test_table").distinct("city"); # 去除

三、索引操作

参考:https://www.cnblogs.com/williamjie/p/9297670.html

mongo 常用命令

原文:https://blog.51cto.com/jinliang/2487908

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!