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