Old Shit

New Shit

Coding

MongoDB Unable to Start on Ubuntu 11.04

Posted on August 25, 2011

I am going to talk much more in depth about MongoDB, NoSQL, Schema-less Collections,  Memory Key/Value store databases in another post. I have been “playing” with MongoDB on my local sandbox for the past 2 weeks and I fucking love it. Anyway, this morning I went to boot up the command line and I was hit with:

mongo Error: couldn’t connect to server 127.0.0.1 (anon):1137

Even if I tried to specify a different port, mongo wouldn’t start. So I searched the internets and tried several different “fixes” that didn’t help. After about 30 minutes of research I finally figured out what is happening and how to fix it. I’m posting it here to help anyone else that has encountered this problem.

From the terminal, run these in order:

  1. sudo rm /var/lib/mongodb/mongod.lock
  2. sudo chown -R mongodb:mongodb /var/lib/mongodb/
  3. sudo -u mongodb mongod -f /etc/mongodb.conf –repair
  4. sudo service mongodb start

Now you can just type “mongo” and it will take you into your test db.

db.test.save({mongo:”fucking awesome”,type:”nosql”,fast:”as fuck”})