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