随笔-193  评论-715  文章-1  trackbacks-0
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 阅读(1600) 评论(0)  编辑  收藏 所属分类: 其它

只有注册用户登录后才能发表评论。


网站导航: