工作中使用了mongo数据库,在这里记录一下常用的命令:
mongo链接
> mongo
> use space_data_collect
switched to db space_data_collect
> db.auth('spacedat!aco3llect','fasd32f!fesa')
# 查询所有数据库列表
show dbs;
# 查看当前连接在哪个数据库下
db
# 想切换到test数据库下面
use test
# 查看数据库有哪些数据表
show collections
show tables
数据库操作
# mongo备份 -- mongodump
./mongodump -d test -o test/
# 删除user表
db.user.drop();
# MongoDB的数据恢复工具mongorestore
./mongorestore -d test -c user test/test/user.bson
简单查询
> show tables
db.media_tag_relation.find({
'media_id':ObjectId("5d834055093c3a093e1dc625")})
db.task_mapping_space.find({
'site_id':86184970,'catalog_id':55});
db.site