Home | 简体中文 | 繁体中文 | 杂文 | 知乎专栏 | 51CTO学院 | CSDN程序员研修院 | Github | OSChina 博客 | 腾讯云社区 | 阿里云栖社区 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏多维度架构

第 43 章 命令工具

目录

43.1. mongo - MongoDB Shell
43.1.1. eval
43.1.2. help
43.1.3. 登陆认证
43.1.4. 管道操作
43.2. mongodump - Backup
43.2.1. 本地备份
43.2.2. 远程备份
43.3. mongorestore
43.3.1. 本地恢复
43.3.2. 远程恢复
43.3.3. filter
43.4. mongostat
43.5. mongotop
43.6. mongofiles - Browse and modify a GridFS filesystem.
43.6.1. list 浏览文件
43.6.2. put 上传文件
43.6.3. get 下载
43.6.4. delete 删除

43.1. mongo - MongoDB Shell

43.1.1. eval

			
# mongo
MongoDB shell version: 2.2.3
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
	http://docs.mongodb.org/
Questions? Try the support group
	http://groups.google.com/group/mongodb-user
>
			
			

3.4

			
[root@netkiller ~]# mongo
MongoDB shell version v3.4.1
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.1
Server has startup warnings: 
2017-01-03T11:26:57.516+0800 I CONTROL  [initandlisten] 
2017-01-03T11:26:57.516+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-01-03T11:26:57.516+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2017-01-03T11:26:57.516+0800 I CONTROL  [initandlisten] 
2017-01-03T11:26:57.516+0800 I CONTROL  [initandlisten] 
2017-01-03T11:26:57.516+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2017-01-03T11:26:57.516+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2017-01-03T11:26:57.516+0800 I CONTROL  [initandlisten] 
2017-01-03T11:26:57.516+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2017-01-03T11:26:57.516+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2017-01-03T11:26:57.516+0800 I CONTROL  [initandlisten] 
>
			
			
# mongo 127.0.0.1:27017/admin --eval "db.stats()"
			

43.1.2. help

help

db.help() help on DB methods
db.foo.help() help on collection methods
			

43.1.3. 登陆认证

			
# mongo -u<user> -p<password> --authenticationDatabase <db> <host>/<db> 
			
			

43.1.4. 管道操作

		
cat data.bson | mongo test