My First Step Into MongoDB – Installing MongoDB on Ubuntu

June 22nd, 2010

MongoDBLately MongoDB become more and more popular in NoSQL movement. For you who haven’t heard about it, MongoDB is a scalable, high-performance, open source, document-oriented database. I always keep my eyes on MongoDB, but never have a chance to really taste the goods. So, right now I want to jump and tame the beast.

First thing first, installing MongoDB on my machine (Ubuntu)

  1. Download MongoDB, I downloaded the latest production version which is 1.4.3
  2. Extract the file.
    $ tar -xvf mongodb-linux-i686-1.4.3.tgz
  3. Create data directory for MongoDB, by default it will store data in /data/db
    $ sudo mkdir -p /data/db/
    $ sudo chown `id -u` /data/db
  4. Run the MongoDB service.
    $ cd mongodb-linux-i686-1.4.3/bin
    $ ./mongod
  5. Open another terminal and make sure you are in MongoDB bin directory and start the shell.
    $ ./mongo

That’s it. Now I can play around with MongoDB.

> db.komunitasweb.save({greeting:'hello world'})
> db.komunitasweb.save({greeting:'good morning'})
> db.komunitasweb.find()
{ "_id" : ObjectId("4c1fd172101b5f3e6fa79d63"), "greeting" : "hello world" }
{ "_id" : ObjectId("4c1fd1c9101b5f3e6fa79d64"), "greeting" : "good morning" }
> db.komunitasweb.find({greeting:"good morning"})
{ "_id" : ObjectId("4c1fd1c9101b5f3e6fa79d64"), "greeting" : "good morning" }

Next time, I’ll show you more about MongoDB as I learn to tame this beast. See you.

Related posts:

  1. Beginner Step Into MongoDB
  2. CakePHP Tutorial:Installing CakePHP on Ubuntu
  3. MongoDB Basic Operations
  4. How to Install OSQA in Ubuntu Server

Tags:

One Comment