Reference page: Http://docs.mongodb.org/master/tutorial/install-mongodb-on-os-x/
1, install brew, if it is exist, skip this step.
Reference page: http://mxcl.github.com/homebrew/
Execute the following command:
#/usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"
2, install MongoDB:
#brew update
#brew install mongodb
3, use mondod command to startup MongoDB
#nohup mongod &
4, enter mongo shell for testing:
#mongo
MongoDB shell version: 2.0.5
connecting to: test
> db.test.save({a:1})
> db.test.find()
{ "_id" : ObjectId("4fca4824293f5115fa740813"), "a" : 1 }
>
5, GUI client recommendations:
MongoExplorer
MongoHub
6, MongoDB has provided a web base management inerface:
http://localhost:28017/
7, export and import:
$ mongodump -h test.xxxx.com:52000 -d dataname -o /home/aa/dev/mongodb/data
mongodump mongo導出數據庫命令 mongodump --help 可以查看該命令下所有的幫助
-h 導出源
-d 要導出的數據庫名稱
-o 數據庫要導出的位置
在終端滾過N行之后,數據庫導出完成,可以去/home/aa/dev/mongodb/data 目錄下查看導出的文件,bson格式的(我導出后沒有馬上就看到文件,等了一會才出現的,原因不明)
然后數據庫恢復使用:mongorestore 命令
$ mongorestore -d cmsdev /home/xx/dev/mongodb/data/cmsdev
-d 使用的數據庫名稱
后面直接加你剛才導出的目錄,這樣是直接恢復所有表
如果-c 是恢復一個表
posted on 2012-06-03 01:15
Robin's Programming World 閱讀(1631)
評論(0) 編輯 收藏 所屬分類:
其它