How to setup MongoDB

Download and install

$ curl > mongo.tgz
$ tar xzf mongo.tgz

Create a data directory

# create default data directory
$ mkdir -p /data/db/
# Grant permission for user-xxx which is the user to run mongodb process
$ chown user-xxx /data/db

Run MongoDB

$ ./mongodb-xxxxxxx/bin/mongod

You should run it with --dbpath parameter like below if data directory is not /data/db/

$ ./mongodb-xxxxxxx/bin/mongod --dbpath=/mnt/ebs/data/mongodb

Add database users

$ ./mongodb-xxxxxxx/bin/mongo
# add a admin user 
> use admin
> db.addUser("admin", "adminpassword")
# add user for poweredsites database
> use poweredsites
> db.addUser("felinx", "felinx")

# show users
> db.system.users.find()

For detail information please refer to the official documentation:

Felinx Lee   August 27, 2010
Comments blog comments powered by Disqus