Home | 简体中文 | 繁体中文 | 杂文 | 打赏(Donations) | Github | OSChina 博客 | 云社区 | 云栖社区 | Facebook | Linkedin | 知乎专栏 | 视频教程 | About

第 13 章 命令工具

目录

13.1. mongo - MongoDB Shell
13.1.1. eval
13.1.2. help
13.1.3. 登陆认证
13.1.4. 管道操作
13.2. mongodump - Backup
13.2.1. 远程备份
13.2.2. 本地备份
13.3. mongorestore
13.3.1. 远程回复
13.3.2. 本地恢复
13.3.3. filter
13.4. mongostat
13.5. mongotop
13.6. mongofiles - Browse and modify a GridFS filesystem.
13.6.1. list 浏览文件
13.6.2. put 上传文件
13.6.3. get 下载
13.6.4. delete 删除

13.1. mongo - MongoDB Shell

13.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()"
			

13.1.2. help

help

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

13.1.3. 登陆认证

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

13.1.4. 管道操作

		
cat data.bson | mongo test