I am trying to figure out MongoDB to evaluate if it will be a route that I would like to use for future applications or not. To deploy it intelligently on my server, I have to run it with authentication enabled (i.e. with the argument --auth or with auth = true in the configuration file).
The installation seems relatively straightforward, and I resorted to documentation if necessary. In particular, the security section explains a good start-up process with auth enabled and the insertion of your first admin user. However, according to the plan, everything is not fulfilled.
Running without auth gives the result you could hope for - it starts with the following output:
Thu Dec 10 21:14:24 Mongo DB : starting : pid = 9350 port = 27017 dbpath = /var/mongodb_data master = 0 slave = 0 64-bit Thu Dec 10 21:14:24 db version v1.3.0-, pdfile version 4.5 Thu Dec 10 21:14:24 git version: 32d56f6d81a98b569103149c9ffea9f25a1ece81 Thu Dec 10 21:14:24 sys info: Darwin erh2.10gen.cc 9.6.0 Darwin Kernel Version 9.6.0: Mon Nov 24 17:37:00 PST 2008; root:xnu-1228.9.59~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_37 Thu Dec 10 21:14:24 waiting for connections on port 27017
However, working with authentication (using either methods, the arg or config directive) gives the following output, and the process ends immediately:
Thu Dec 10 21:15:37 Mongo DB : starting : pid = 9361 port = 27017 dbpath = /var/mongodb_data master = 0 slave = 0 64-bit Thu Dec 10 21:15:37 User Exception unauthorized Thu Dec 10 21:15:37 local.system.namespaces Caught Assertion in runQuery ns:local.system.namespaces userassert:unauthorized Thu Dec 10 21:15:37 ntoskip:0 ntoreturn:0 Thu Dec 10 21:15:37 query:{ name: /^local.temp./ } Thu Dec 10 21:15:37 query local.system.namespaces ntoreturn:0 exception 0ms Thu Dec 10 21:15:37 Dropping old temporary collection: Thu Dec 10 21:15:37 User Exception no collection name Thu Dec 10 21:15:37 exception in initAndListen std::exception: no collection name, terminating Thu Dec 10 21:15:37 dbexit: Thu Dec 10 21:15:37 shutdown: going to flush oplog... Thu Dec 10 21:15:37 shutdown: going to close sockets... Thu Dec 10 21:15:37 shutdown: waiting for fs... Thu Dec 10 21:15:37 shutdown: closing all files... Thu Dec 10 21:15:37 closeAllFiles() finished Thu Dec 10 21:15:37 shutdown: removing fs lock... Thu Dec 10 21:15:37 dbexit: really exiting now ERROR: Client::shutdown not called!
As noted in the tags, this works on OS X Snow Leopard, and it uses the latest downloadable binary version of OS X with the 64-bit version 1.3.x (if I get back to 1.2 stable, maybe?)
Any idea what causes this and what can I do to solve this problem? This is not so important on my local machine, but I need it to work in safe mode to make it practically applicable for any use in production.
PS: if it should be on ServerFault, not SO, feel free to move it there. I was not sure which environment was best.
Update:
I tried working without auth, adding a user and reusing auth, as recommended by mdirolf and Mathias. However, he still throws the same error. The user was added as follows:
Mark@Destiny mongodb$ sudo bin/mongo MongoDB shell version: 1.3.0- url: test connecting to: test type "help" for help > use admin switched to db admin > db.addUser("Mark", "my-password-went-here") { "user" : "Mark", "pwd" : "9934...be15da0" } > db.system.users.find() { "_id" : ObjectId("4b216ed0be8a0b185767654e"), "user" : "Mark", "pwd" : "9934a190b...babe15da0" } > exit bye
Subsequent startup without authorization and entry into the mongo shell proves that the user is actually still there. Am I doing something stupid?