How I Scrapped MySQL for MongoDB in Three Hours

Last weekend at the AT&T Mobile Hackathon I had a pleasure of checking out the MongoLab's MongoDB service.  In short: it was a delight to work with.  I fell in love with that technology.  It worked exactly the way I thought--MongoDB architects got it right. After spending a good part of the day fighting my hibernate configuration in JUnit I was pleasantly surprised when I saw that Mongo keeps their documentation and design accessible with plan old object and simple REST calls to its MongoLab API.

MongoLab makes creating a MongoDB super easy.  You can sign up for a dev account and within minutes get an instance that will hold up to 240MB of data.  It's perfect for a prototype. In 15 minutes I was up and running and had my unit test executing flawlessly. It took a couple of more hours to refactor the application to move my serialization from MySQL + Hibernate to MongoDB.  In a total of three hours the port was complete.

The web interface on MongoDB made it easy to see if my app was serializing data correctly.  I created one collection for Unit Test and another collection for my production data. Collections can be limited in the number of records so they wouldn't flood my account with test data.

MongoLab Admin View

Working with Mongo right after working with Hibernate and MySQL made me realize something.  In 2000-2007 we built up some complicated protocols and frameworks. The last couple of year the simplicity seems to have taken off.  A lot of people wrote off Java because of the complexities, but I can tell you that Spring+Annotations and MongoDB brings the joy back to Java web development again.

Be sure to read the next API article: Music Licensing API Lets You Sound Legally Awesome


Comments (11)

[...] week we had 45 new APIs added to our API directory including a hosted MongoDB database, live chat platform, fact sharing service, podcast retrieval service, distributed graph database, [...]

[...] How I Scrapped MySQL for MongoDB in Three Hours – I can tell you that Spring+Annotations and MongoDB brings the joy back to Java web development again [...]

I want to love MongoDB, but there are several issues I have with it.

1.) Security. You can password protect against writes, but you can read with out having authed against it.

2.) No built in joins, you have to do this external. You can do with CouchDB.

3.) No Master/Master replication. Only Master/Slave.

[...] databases are all the rage these days. We recently discussed moving from MySQL to MongoDB within hours. The rise of NoSQL is often associated with the need to not just store large amounts [...]

are you sure you can read without a password? It seems like there is a password on connection in my tests. I assumed that prevents reads and writes.

Have you tested the version deployed by MongoLab?


If you were using Ruby, you could have quickly moved your mySQL data to MongoDB by using Mongify (

It's a super simple way to transform your data from a RDBS to MongoDB without losing anything.

Mongify will read your mysql database, build a translation file for you and all you have to do is map how you want your data transformed.

It supports:

* Updating internal IDs (to BSON ObjectID)

* Updating referencing IDs

* Type Casting values

* Embedding Tables into other documents

* Before filters (to change data manually)

* and much much more...

Read more about it at:

There is also a short 5 min video on the homepage that shows you how easy it is.


Right here is the right blog for everyone who would like to understand this topic.

You understand so much its almost hard to argue with you (not

that I personally would want to…HaHa). You certainly put a

fresh spin on a topic that's been written about for decades. Great stuff, just excellent!


You're probably not counting the several ours it took you to sit in on sessions learning Mongo, but I can tell you from firsthand experience with Mongo that a 3 hour port tells me that your application is extremely simple.

Your application probably has only a dozen tables, no functions, no stored procedures, no complicated relationships, queries or joins. A real production backend will have all those things and require many man months to do a basic Mongo migration, all of the debug required and the necessary performance tuning and learning along the way, interspersed with finding forums like these that explain how to get yourself out of the trouble you got yourself into. We eventually paid to have two 10Gen techies come in for a day to help us out in establishing new guidelines and best practices for managing Mongo with our very large legacy application. In other words, we had to redesign parts of our Mongo adapters per their recommendations, adding more time and effort to the already extended project.

I'm not complaining, but I'm outlining for everybody what realistically to expect