Linux安装MongoDb
1、创建目录/data/db、/data/logs
mkdir -p /data/db
mkdir -p /data/logs
2、在/mongodb-linux-i686-2.2.1/bin/下建立mongodb.conf文件,内容为:
dbpath = /data/db
logpath = /data/logs/mongodb.log
port = 27017
fork = true
3、启动mongo程序
./mongod --config mongodb.conf
4、运行结果
forked process: 15325
all output going to: /data/logs/mongodb.log
child process started successfully, parent exiting
./mongo
MongoDB shell version: 2.2.1
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
> user={"name":"edward", "blogUrl":"http://edward.com"}
{ "name" : "edward", "blogUrl" : "http://edward.com" }
> db.user.insert(user)
> db.user.find();
{ "_id" : ObjectId("50a23c53d3f17e875907c19f"), "name" : "edward", "blogUrl" : "http://edward.com" }