2

I'm trying to connect to a MongoDB database that requires a password while also loading and running a script file on the database. I want to do it all from the command line and have the mongo shell exit afterwards. My problem is that I cannot do both at the same time, e.g.

$ mongo example.com:10023/database -u username -p script.js

The above command will think that script.js is actually my password, which it of cause isn't. I want it to actually prompt me for my password after I enter the command.

How can I do that?

Thomas Watson
  • 6,507
  • 5
  • 33
  • 43

1 Answers1

4

Try moving the arguments around so that script.js does not follow your password parameter.

$mongo example.com:10023/database script.js -u username -p

Andre de Frere
  • 2,703
  • 16
  • 13
  • 1
    So freaking simple. And yet I never thought about moving the arguments around. Why? Because " .. Must be the last option specified.". Thanks! – cybertoast Sep 24 '13 at 13:34