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

第 44 章 命令工具

目录

44.1. mongo - MongoDB Shell
44.1.1. eval
44.1.2. help
44.1.3. 登陆认证
44.1.4. 管道操作
44.2. mongodump - Backup
44.2.1. 远程备份
44.2.2. 本地备份
44.3. mongorestore
44.3.1. 远程回复
44.3.2. 本地恢复
44.3.3. filter
44.4. mongostat
44.5. mongotop
44.6. mongofiles - Browse and modify a GridFS filesystem.
44.6.1. list 浏览文件
44.6.2. put 上传文件
44.6.3. get 下载
44.6.4. delete 删除

44.1. mongo - MongoDB Shell

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

44.1.2. help

help

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

44.1.3. 登陆认证

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

44.1.4. 管道操作

		
cat data.bson | mongo test