Steve is Dead, time to try MongoDB

A few weeks ago I went to an event called #seedhack.  I met a chap there called Russel Smith.  He seemed to know quite a bit about MongoDB and was kind enough to sit down and spend a few hours with me, beating the benefits of not having a schema into my head.

I was dubious about becoming one of those NoSQL ‘wankers’ as my friend Tom refers to them as.  So I decided to tread lightly.

Today, after two weeks of discussing what we want to do with the new internals of I started using MongoDB. I thought I would document my progress so others might not fall into the same traps I did.

I am setting up a MongoDB instance on a Ubuntu server that has an existing apache2 and php5 instance installed.  I typed the following in as root:

apt-get install mongodb-server
apt-get install pecl
sudo pecl install mongo
vi /etc/php5/apache2/conf.d/mongo.ini
I then put the following line in the file:

Restart apache:

apache2ctl stop
apache2ctl start

Quite simple really.  I had played with MongoDB two weeks ago when Russel was showing me around, so I was able to dump the database I had using the following command:

mongodump -db tribe

It managed to make a number of directories and files under a local directory called dump.  I then scp’d that over to the new server I was setting up and used the following command to import the dump.

It should be noted that you don’t have any concept of database of schema in MongoDB.  They just sort of get created when you need them. (sounds fine to me)

To do the restore just sit above the dump directory and type:


That’s Mongo Restore incase you didn’t notice the ‘r’.  It magically worked and I was then able to connect to the db from PHP5 (Under Apache – you need to do the conf.d/mongo.ini under cli if you want it to work from the command line) and read and write my data.  Brilliant.  How easy is that?!?!


About slushfundsupervisor

I work in the tech industry and have done for a long time. So, I have opinions. I like to share them.
This entry was posted in Uncategorized and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s