Alex Rivera | Logout

Creating a database in Mongo: can't connect, get "connect failed"

Asked 2010-12-21T18:18:01.573
27

I want to create a new database in Mongo. However, I'm having trouble connecting:

:~$ mongo
MongoDB shell version: 1.6.5
connecting to: test
Tue Dec 21 18:16:25 Error: couldn't connect to server 127.0.0.1 (anon):1154
exception: connect failed

How can I connect to mongo in order to create a new database? Alternatively, can I create a new database from the command line?

Slightly surprisingly, the Mongo docs don't seem to cover how to create a database.

Thanks.

Edit
Report

1 Answer

24
  1. cd /var/lib/mongodb/

  2. remove mongod.lock file from this folder

  3. sudo start mongodb (in console)

  4. mongo (in console)

    And it runs fine.

answered 2011-12-29T11:26:35.533

Your Answer